240 #ifndef NK_NUKLEAR_H_
241 #define NK_NUKLEAR_H_
253 #define NK_UNDEFINED (-1.0f)
254 #define NK_UTF_INVALID 0xFFFD
255 #define NK_UTF_SIZE 4
257 #define NK_INPUT_MAX 16
259 #ifndef NK_MAX_NUMBER_BUFFER
260 #define NK_MAX_NUMBER_BUFFER 64
262 #ifndef NK_SCROLLBAR_HIDING_TIMEOUT
263 #define NK_SCROLLBAR_HIDING_TIMEOUT 4.0f
274 #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199409L))
275 #define NK_API static inline
276 #elif defined(__cplusplus)
277 #define NK_API static inline
279 #define NK_API static
282 #define NK_API extern
286 #define NK_INTERN static
287 #define NK_STORAGE static
288 #define NK_GLOBAL static
290 #define NK_FLAG(x) (1 << (x))
291 #define NK_STRINGIFY(x) #x
292 #define NK_MACRO_STRINGIFY(x) NK_STRINGIFY(x)
293 #define NK_STRING_JOIN_IMMEDIATE(arg1, arg2) arg1 ## arg2
294 #define NK_STRING_JOIN_DELAY(arg1, arg2) NK_STRING_JOIN_IMMEDIATE(arg1, arg2)
295 #define NK_STRING_JOIN(arg1, arg2) NK_STRING_JOIN_DELAY(arg1, arg2)
298 #define NK_UNIQUE_NAME(name) NK_STRING_JOIN(name,__COUNTER__)
300 #define NK_UNIQUE_NAME(name) NK_STRING_JOIN(name,__LINE__)
303 #ifndef NK_STATIC_ASSERT
304 #define NK_STATIC_ASSERT(exp) typedef char NK_UNIQUE_NAME(_dummy_array)[(exp)?1:-1]
309 #define NK_FILE_LINE __FILE__ ":" NK_MACRO_STRINGIFY(__COUNTER__)
311 #define NK_FILE_LINE __FILE__ ":" NK_MACRO_STRINGIFY(__LINE__)
315 #define NK_MIN(a,b) ((a) < (b) ? (a) : (b))
316 #define NK_MAX(a,b) ((a) < (b) ? (b) : (a))
317 #define NK_CLAMP(i,v,x) (NK_MAX(NK_MIN(v,x), i))
325 #ifdef NK_INCLUDE_FIXED_TYPES
327 #define NK_INT8 int8_t
328 #define NK_UINT8 uint8_t
329 #define NK_INT16 int16_t
330 #define NK_UINT16 uint16_t
331 #define NK_INT32 int32_t
332 #define NK_UINT32 uint32_t
333 #define NK_SIZE_TYPE uintptr_t
334 #define NK_POINTER_TYPE uintptr_t
340 #define NK_UINT8 unsigned char
343 #define NK_INT16 signed short
346 #define NK_UINT16 unsigned short
349 #if defined(_MSC_VER)
350 #define NK_INT32 __int32
352 #define NK_INT32 signed int
356 #if defined(_MSC_VER)
357 #define NK_UINT32 unsigned __int32
359 #define NK_UINT32 unsigned int
363 #if defined(_WIN64) && defined(_MSC_VER)
364 #define NK_SIZE_TYPE unsigned __int64
365 #elif (defined(_WIN32) || defined(WIN32)) && defined(_MSC_VER)
366 #define NK_SIZE_TYPE unsigned __int32
367 #elif defined(__GNUC__) || defined(__clang__)
368 #if defined(__x86_64__) || defined(__ppc64__)
369 #define NK_SIZE_TYPE unsigned long
371 #define NK_SIZE_TYPE unsigned int
374 #define NK_SIZE_TYPE unsigned long
377 #ifndef NK_POINTER_TYPE
378 #if defined(_WIN64) && defined(_MSC_VER)
379 #define NK_POINTER_TYPE unsigned __int64
380 #elif (defined(_WIN32) || defined(WIN32)) && defined(_MSC_VER)
381 #define NK_POINTER_TYPE unsigned __int32
382 #elif defined(__GNUC__) || defined(__clang__)
383 #if defined(__x86_64__) || defined(__ppc64__)
384 #define NK_POINTER_TYPE unsigned long
386 #define NK_POINTER_TYPE unsigned int
389 #define NK_POINTER_TYPE unsigned long
429 struct nk_draw_command;
437 struct nk_draw_vertex_layout_element;
441 struct nk_style_slide;
540 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
600 #ifdef NK_INCLUDE_COMMAND_USERDATA
1011 #define nk_foreach(c, ctx) for((c) = nk__begin(ctx); (c) != 0; (c) = nk__next(ctx,c))
1012 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
1047 NK_API const struct nk_draw_command* nk__draw_next(
const struct nk_draw_command*,
const struct nk_buffer*,
const struct nk_context*);
1053 #define nk_draw_foreach(cmd,ctx, b) for((cmd)=nk__draw_begin(ctx, b); (cmd)!=0; (cmd)=nk__draw_next(cmd, b, ctx))
1694 #define nk_tree_push(ctx, type, title, state) nk_tree_push_hashed(ctx, type, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),__LINE__)
1695 #define nk_tree_push_id(ctx, type, title, state, id) nk_tree_push_hashed(ctx, type, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),id)
1697 #define nk_tree_image_push(ctx, type, img, title, state) nk_tree_image_push_hashed(ctx, type, img, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),__LINE__)
1698 #define nk_tree_image_push_id(ctx, type, img, title, state, id) nk_tree_image_push_hashed(ctx, type, img, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),id)
1762 #ifdef NK_INCLUDE_STANDARD_VARARGS
1769 NK_API void nk_value_uint(
struct nk_context*,
const char *prefix,
unsigned int);
1870 NK_API double nk_propertyd(
struct nk_context*,
const char *name,
double min,
double val,
double max,
double step,
float inc_per_pixel);
2192 NK_API const char*
nk_utf_at(
const char *buffer,
int length,
int index, nk_rune *unicode,
int *len);
2342 struct nk_user_font_glyph;
2345 struct nk_user_font_glyph *glyph,
2346 nk_rune codepoint, nk_rune next_codepoint);
2348 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
2349 struct nk_user_font_glyph {
2354 float width, height;
2368 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
2376 #ifdef NK_INCLUDE_FONT_BAKING
2377 enum nk_font_coord_type {
2382 struct nk_baked_font {
2385 float ascent, descent;
2387 nk_rune glyph_offset;
2389 nk_rune glyph_count;
2391 const nk_rune *ranges;
2395 struct nk_font_config {
2396 struct nk_font_config *next;
2405 unsigned char ttf_data_owned_by_atlas;
2407 unsigned char merge_mode;
2409 unsigned char pixel_snap;
2411 unsigned char oversample_v, oversample_h;
2413 unsigned char padding[3];
2417 enum nk_font_coord_type coord_type;
2421 const nk_rune *range;
2423 struct nk_baked_font *font;
2425 nk_rune fallback_glyph;
2429 struct nk_font_glyph {
2432 float x0, y0, x1, y1, w, h;
2433 float u0, v0, u1, v1;
2437 struct nk_font *next;
2439 struct nk_baked_font info;
2441 struct nk_font_glyph *glyphs;
2442 const struct nk_font_glyph *fallback;
2443 nk_rune fallback_codepoint;
2445 struct nk_font_config *
config;
2448 enum nk_font_atlas_format {
2449 NK_FONT_ATLAS_ALPHA8,
2450 NK_FONT_ATLAS_RGBA32
2453 struct nk_font_atlas {
2465 struct nk_font_glyph *glyphs;
2466 struct nk_font *default_font;
2467 struct nk_font *fonts;
2468 struct nk_font_config *
config;
2473 NK_API const nk_rune *nk_font_default_glyph_ranges(
void);
2474 NK_API const nk_rune *nk_font_chinese_glyph_ranges(
void);
2475 NK_API const nk_rune *nk_font_cyrillic_glyph_ranges(
void);
2476 NK_API const nk_rune *nk_font_korean_glyph_ranges(
void);
2478 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
2479 NK_API void nk_font_atlas_init_default(
struct nk_font_atlas*);
2483 NK_API void nk_font_atlas_begin(
struct nk_font_atlas*);
2484 NK_API struct nk_font_config nk_font_config(float pixel_height);
2485 NK_API struct nk_font *nk_font_atlas_add(
struct nk_font_atlas*,
const struct nk_font_config*);
2486 #ifdef NK_INCLUDE_DEFAULT_FONT
2487 NK_API struct nk_font* nk_font_atlas_add_default(
struct nk_font_atlas*,
float height,
const struct nk_font_config*);
2489 NK_API struct nk_font* nk_font_atlas_add_from_memory(
struct nk_font_atlas *atlas,
void *memory, nk_size size,
float height,
const struct nk_font_config *
config);
2490 #ifdef NK_INCLUDE_STANDARD_IO
2491 NK_API struct nk_font* nk_font_atlas_add_from_file(
struct nk_font_atlas *atlas,
const char *file_path,
float height,
const struct nk_font_config*);
2493 NK_API struct nk_font *nk_font_atlas_add_compressed(
struct nk_font_atlas*,
void *memory, nk_size size,
float height,
const struct nk_font_config*);
2494 NK_API struct nk_font* nk_font_atlas_add_compressed_base85(
struct nk_font_atlas*,
const char *data,
float height,
const struct nk_font_config *
config);
2495 NK_API const void* nk_font_atlas_bake(
struct nk_font_atlas*,
int *width,
int *height,
enum nk_font_atlas_format);
2497 NK_API const struct nk_font_glyph* nk_font_find_glyph(
struct nk_font*, nk_rune unicode);
2498 NK_API void nk_font_atlas_cleanup(
struct nk_font_atlas *atlas);
2499 NK_API void nk_font_atlas_clear(
struct nk_font_atlas*);
2583 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
2613 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
2682 #ifndef NK_TEXTEDIT_UNDOSTATECOUNT
2683 #define NK_TEXTEDIT_UNDOSTATECOUNT 99
2686 #ifndef NK_TEXTEDIT_UNDOCHARCOUNT
2687 #define NK_TEXTEDIT_UNDOCHARCOUNT 999
2754 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
2844 #ifdef NK_INCLUDE_COMMAND_USERDATA
2980 unsigned short w,
unsigned short h, nk_handle callback_data);
3016 NK_API void nk_stroke_curve(
struct nk_command_buffer*,
float,
float,
float,
float,
float,
float,
float,
float,
float line_thickness,
struct nk_color);
3095 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
3109 typedef nk_ushort nk_draw_index;
3110 enum nk_draw_list_stroke {
3117 enum nk_draw_vertex_layout_attribute {
3121 NK_VERTEX_ATTRIBUTE_COUNT
3124 enum nk_draw_vertex_layout_format {
3134 NK_FORMAT_COLOR_BEGIN,
3135 NK_FORMAT_R8G8B8 = NK_FORMAT_COLOR_BEGIN,
3136 NK_FORMAT_R16G15B16,
3137 NK_FORMAT_R32G32B32,
3140 NK_FORMAT_R16G15B16A16,
3141 NK_FORMAT_R32G32B32A32,
3142 NK_FORMAT_R32G32B32A32_FLOAT,
3143 NK_FORMAT_R32G32B32A32_DOUBLE,
3147 NK_FORMAT_COLOR_END = NK_FORMAT_RGBA32,
3151 #define NK_VERTEX_LAYOUT_END NK_VERTEX_ATTRIBUTE_COUNT,NK_FORMAT_COUNT,0
3152 struct nk_draw_vertex_layout_element {
3153 enum nk_draw_vertex_layout_attribute attribute;
3154 enum nk_draw_vertex_layout_format format;
3158 struct nk_draw_command {
3159 unsigned int elem_count;
3165 #ifdef NK_INCLUDE_COMMAND_USERDATA
3170 struct nk_draw_list {
3172 struct nk_vec2 circle_vtx[12];
3179 unsigned int element_count;
3180 unsigned int vertex_count;
3181 unsigned int cmd_count;
3184 unsigned int path_count;
3185 unsigned int path_offset;
3187 #ifdef NK_INCLUDE_COMMAND_USERDATA
3193 NK_API void nk_draw_list_init(
struct nk_draw_list*);
3195 NK_API void nk_draw_list_clear(
struct nk_draw_list*);
3198 #define nk_draw_list_foreach(cmd, can, b) for((cmd)=nk__draw_list_begin(can, b); (cmd)!=0; (cmd)=nk__draw_list_next(cmd, b, can))
3199 NK_API const struct nk_draw_command* nk__draw_list_begin(
const struct nk_draw_list*,
const struct nk_buffer*);
3200 NK_API const struct nk_draw_command* nk__draw_list_next(
const struct nk_draw_command*,
const struct nk_buffer*,
const struct nk_draw_list*);
3201 NK_API const struct nk_draw_command* nk__draw_list_end(
const struct nk_draw_list*,
const struct nk_buffer*);
3202 NK_API void nk_draw_list_clear(
struct nk_draw_list *list);
3205 NK_API void nk_draw_list_path_clear(
struct nk_draw_list*);
3206 NK_API void nk_draw_list_path_line_to(
struct nk_draw_list*,
struct nk_vec2 pos);
3207 NK_API void nk_draw_list_path_arc_to_fast(
struct nk_draw_list*,
struct nk_vec2 center,
float radius,
int a_min,
int a_max);
3208 NK_API void nk_draw_list_path_arc_to(
struct nk_draw_list*,
struct nk_vec2 center,
float radius,
float a_min,
float a_max,
unsigned int segments);
3209 NK_API void nk_draw_list_path_rect_to(
struct nk_draw_list*,
struct nk_vec2 a,
struct nk_vec2 b,
float rounding);
3210 NK_API void nk_draw_list_path_curve_to(
struct nk_draw_list*,
struct nk_vec2 p2,
struct nk_vec2 p3,
struct nk_vec2 p4,
unsigned int num_segments);
3211 NK_API void nk_draw_list_path_fill(
struct nk_draw_list*,
struct nk_color);
3212 NK_API void nk_draw_list_path_stroke(
struct nk_draw_list*,
struct nk_color,
enum nk_draw_list_stroke closed,
float thickness);
3216 NK_API void nk_draw_list_stroke_rect(
struct nk_draw_list*,
struct nk_rect rect,
struct nk_color,
float rounding,
float thickness);
3218 NK_API void nk_draw_list_stroke_circle(
struct nk_draw_list*,
struct nk_vec2 center,
float radius,
struct nk_color,
unsigned int segs,
float thickness);
3220 NK_API void nk_draw_list_stroke_poly_line(
struct nk_draw_list*,
const struct nk_vec2 *pnts,
const unsigned int cnt,
struct nk_color,
enum nk_draw_list_stroke,
float thickness,
enum nk_anti_aliasing);
3223 NK_API void nk_draw_list_fill_rect(
struct nk_draw_list*,
struct nk_rect rect,
struct nk_color,
float rounding);
3226 NK_API void nk_draw_list_fill_circle(
struct nk_draw_list*,
struct nk_vec2 center,
float radius,
struct nk_color col,
unsigned int segs);
3231 NK_API void nk_draw_list_add_text(
struct nk_draw_list*,
const struct nk_user_font*,
struct nk_rect,
const char *text,
int len,
float font_height,
struct nk_color);
3232 #ifdef NK_INCLUDE_COMMAND_USERDATA
3233 NK_API void nk_draw_list_push_userdata(
struct nk_draw_list*, nk_handle userdata);
3682 #ifndef NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS
3683 #define NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS 16
3685 #ifndef NK_CHART_MAX_SLOT
3686 #define NK_CHART_MAX_SLOT 4
3782 #ifndef NK_WINDOW_MAX_NAME
3783 #define NK_WINDOW_MAX_NAME 64
3896 #ifndef NK_BUTTON_BEHAVIOR_STACK_SIZE
3897 #define NK_BUTTON_BEHAVIOR_STACK_SIZE 8
3900 #ifndef NK_FONT_STACK_SIZE
3901 #define NK_FONT_STACK_SIZE 8
3904 #ifndef NK_STYLE_ITEM_STACK_SIZE
3905 #define NK_STYLE_ITEM_STACK_SIZE 16
3908 #ifndef NK_FLOAT_STACK_SIZE
3909 #define NK_FLOAT_STACK_SIZE 32
3912 #ifndef NK_VECTOR_STACK_SIZE
3913 #define NK_VECTOR_STACK_SIZE 16
3916 #ifndef NK_FLAGS_STACK_SIZE
3917 #define NK_FLAGS_STACK_SIZE 32
3920 #ifndef NK_COLOR_STACK_SIZE
3921 #define NK_COLOR_STACK_SIZE 32
3924 #define NK_CONFIGURATION_STACK_TYPE(prefix, name, type)\
3925 struct nk_config_stack_##name##_element {\
3926 prefix##_##type *address;\
3927 prefix##_##type old_value;\
3929 #define NK_CONFIG_STACK(type,size)\
3930 struct nk_config_stack_##type {\
3932 struct nk_config_stack_##type##_element elements[size];\
3935 #define nk_float float
3965 #define NK_VALUE_PAGE_CAPACITY \
3966 ((NK_MAX(sizeof(struct nk_window),sizeof(struct nk_panel)) / sizeof(nk_uint)) / 2)
4018 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
4019 struct nk_draw_list draw_list;
4021 #ifdef NK_INCLUDE_COMMAND_USERDATA
4048 #define NK_PI 3.141592654f
4049 #define NK_UTF_INVALID 0xFFFD
4050 #define NK_MAX_FLOAT_PRECISION 2
4052 #define NK_UNUSED(x) ((void)(x))
4053 #define NK_SATURATE(x) (NK_MAX(0, NK_MIN(1.0f, x)))
4054 #define NK_LEN(a) (sizeof(a)/sizeof(a)[0])
4055 #define NK_ABS(a) (((a) < 0) ? -(a) : (a))
4056 #define NK_BETWEEN(x, a, b) ((a) <= (x) && (x) < (b))
4057 #define NK_INBOX(px, py, x, y, w, h)\
4058 (NK_BETWEEN(px,x,x+w) && NK_BETWEEN(py,y,y+h))
4059 #define NK_INTERSECT(x0, y0, w0, h0, x1, y1, w1, h1) \
4060 (!(((x1 > (x0 + w0)) || ((x1 + w1) < x0) || (y1 > (y0 + h0)) || (y1 + h1) < y0)))
4061 #define NK_CONTAINS(x, y, w, h, bx, by, bw, bh)\
4062 (NK_INBOX(x,y, bx, by, bw, bh) && NK_INBOX(x+w,y+h, bx, by, bw, bh))
4064 #define nk_vec2_sub(a, b) nk_vec2((a).x - (b).x, (a).y - (b).y)
4065 #define nk_vec2_add(a, b) nk_vec2((a).x + (b).x, (a).y + (b).y)
4066 #define nk_vec2_len_sqr(a) ((a).x*(a).x+(a).y*(a).y)
4067 #define nk_vec2_muls(a, t) nk_vec2((a).x * (t), (a).y * (t))
4069 #define nk_ptr_add(t, p, i) ((t*)((void*)((nk_byte*)(p) + (i))))
4070 #define nk_ptr_add_const(t, p, i) ((const t*)((const void*)((const nk_byte*)(p) + (i))))
4071 #define nk_zero_struct(s) nk_zero(&s, sizeof(s))
4077 #if defined(__PTRDIFF_TYPE__)
4078 # define NK_UINT_TO_PTR(x) ((void*)(__PTRDIFF_TYPE__)(x))
4079 # define NK_PTR_TO_UINT(x) ((nk_size)(__PTRDIFF_TYPE__)(x))
4080 #elif !defined(__GNUC__)
4081 # define NK_UINT_TO_PTR(x) ((void*)&((char*)0)[x])
4082 # define NK_PTR_TO_UINT(x) ((nk_size)(((char*)x)-(char*)0))
4083 #elif defined(NK_USE_FIXED_TYPES)
4084 # define NK_UINT_TO_PTR(x) ((void*)(uintptr_t)(x))
4085 # define NK_PTR_TO_UINT(x) ((uintptr_t)(x))
4087 # define NK_UINT_TO_PTR(x) ((void*)(x))
4088 # define NK_PTR_TO_UINT(x) ((nk_size)(x))
4091 #define NK_ALIGN_PTR(x, mask)\
4092 (NK_UINT_TO_PTR((NK_PTR_TO_UINT((nk_byte*)(x) + (mask-1)) & ~(mask-1))))
4093 #define NK_ALIGN_PTR_BACK(x, mask)\
4094 (NK_UINT_TO_PTR((NK_PTR_TO_UINT((nk_byte*)(x)) & ~(mask-1))))
4096 #define NK_OFFSETOF(st,m) ((nk_ptr)&(((st*)0)->m))
4097 #define NK_CONTAINER_OF(ptr,type,member)\
4098 (type*)((void*)((char*)(1 ? (ptr): &((type*)0)->member) - NK_OFFSETOF(type, member)))
4105 template<
typename T>
struct nk_alignof;
4106 template<
typename T,
int size_diff>
struct nk_helper{
enum {
value = size_diff};};
4108 template<
typename T>
struct nk_alignof{
struct Big {T x;
char c;};
enum {
4110 #define NK_ALIGNOF(t) (nk_alignof<t>::value);
4111 #elif defined(_MSC_VER)
4112 #define NK_ALIGNOF(t) (__alignof(t))
4114 #define NK_ALIGNOF(t) ((char*)(&((struct {char c; t _h;}*)0)->_h) - (char*)0)
4125 #ifdef NK_IMPLEMENTATION
4127 #ifndef NK_POOL_DEFAULT_CAPACITY
4128 #define NK_POOL_DEFAULT_CAPACITY 16
4131 #ifndef NK_DEFAULT_COMMAND_BUFFER_SIZE
4132 #define NK_DEFAULT_COMMAND_BUFFER_SIZE (4*1024)
4135 #ifndef NK_BUFFER_DEFAULT_INITIAL_SIZE
4136 #define NK_BUFFER_DEFAULT_INITIAL_SIZE (4*1024)
4140 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
4143 #ifdef NK_INCLUDE_STANDARD_IO
4146 #ifdef NK_INCLUDE_STANDARD_VARARGS
4151 #define NK_ASSERT(expr) assert(expr)
4155 #define NK_MEMSET nk_memset
4158 #define NK_MEMCPY nk_memcopy
4161 #define NK_SQRT nk_sqrt
4164 #define NK_SIN nk_sin
4167 #define NK_COS nk_cos
4170 #define NK_STRTOD nk_strtod
4173 #define NK_DTOA nk_dtoa
4176 #define NK_DEFAULT (-1)
4178 #ifndef NK_VSNPRINTF
4183 #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) ||\
4184 (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
4185 (defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L)) ||\
4186 (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)) ||\
4187 defined(_ISOC99_SOURCE) || defined(_BSD_SOURCE)
4188 #define NK_VSNPRINTF(s,n,f,a) vsnprintf(s,n,f,a)
4190 #define NK_VSNPRINTF(s,n,f,a) vsprintf(s,f,a)
4194 #define NK_SCHAR_MIN (-127)
4195 #define NK_SCHAR_MAX 127
4196 #define NK_UCHAR_MIN 0
4197 #define NK_UCHAR_MAX 256
4198 #define NK_SSHORT_MIN (-32767)
4199 #define NK_SSHORT_MAX 32767
4200 #define NK_USHORT_MIN 0
4201 #define NK_USHORT_MAX 65535
4202 #define NK_SINT_MIN (-2147483647)
4203 #define NK_SINT_MAX 2147483647
4204 #define NK_UINT_MIN 0
4205 #define NK_UINT_MAX 4294967295u
4220 NK_GLOBAL const struct nk_rect nk_null_rect = {-8192.0f, -8192.0f, 16384, 16384};
4221 #define NK_FLOAT_PRECISION 0.00000000000001
4265 nk_inv_sqrt(
float number)
4268 const float threehalfs = 1.5f;
4269 union {nk_uint i;
float f;} conv = {0};
4272 conv.i = 0x5f375A84 - (conv.i >> 1);
4273 conv.f = conv.f * (threehalfs - (x2 * conv.f * conv.f));
4280 return x * nk_inv_sqrt(x);
4286 NK_STORAGE const float a0 = +1.91059300966915117e-31f;
4287 NK_STORAGE const float a1 = +1.00086760103908896f;
4288 NK_STORAGE const float a2 = -1.21276126894734565e-2f;
4289 NK_STORAGE const float a3 = -1.38078780785773762e-1f;
4290 NK_STORAGE const float a4 = -2.67353392911981221e-2f;
4291 NK_STORAGE const float a5 = +2.08026600266304389e-2f;
4292 NK_STORAGE const float a6 = -3.03996055049204407e-3f;
4293 NK_STORAGE const float a7 = +1.38235642404333740e-4f;
4294 return a0 + x*(a1 + x*(a2 + x*(a3 + x*(a4 + x*(a5 + x*(a6 + x*a7))))));
4300 NK_STORAGE const float a0 = +1.00238601909309722f;
4301 NK_STORAGE const float a1 = -3.81919947353040024e-2f;
4302 NK_STORAGE const float a2 = -3.94382342128062756e-1f;
4303 NK_STORAGE const float a3 = -1.18134036025221444e-1f;
4304 NK_STORAGE const float a4 = +1.07123798512170878e-1f;
4305 NK_STORAGE const float a5 = -1.86637164165180873e-2f;
4306 NK_STORAGE const float a6 = +9.90140908664079833e-4f;
4307 NK_STORAGE const float a7 = -5.23022132118824778e-14f;
4308 return a0 + x*(a1 + x*(a2 + x*(a3 + x*(a4 + x*(a5 + x*(a6 + x*a7))))));
4312 nk_round_up_pow2(nk_uint v)
4327 return nk_null_rect;
4353 return nk_rect(pos.x, pos.y, size.x, size.y);
4359 return nk_rect(r[0], r[1], r[2], r[3]);
4365 return nk_recti(r[0], r[1], r[2], r[3]);
4372 ret.
x = r.x; ret.y = r.y;
4380 ret.
x = r.w; ret.y = r.h;
4385 nk_shrink_rect(struct
nk_rect r, float amount)
4388 r.
w =
NK_MAX(r.w, 2 * amount);
4389 r.h =
NK_MAX(r.h, 2 * amount);
4390 res.x = r.x + amount;
4391 res.y = r.y + amount;
4392 res.w = r.w - 2 * amount;
4393 res.h = r.h - 2 * amount;
4401 r.h =
NK_MAX(r.h, 2 * pad.y);
4402 r.x += pad.x; r.y += pad.y;
4412 ret.
x =
x; ret.y =
y;
4444 NK_INTERN int nk_str_match_here(
const char *regexp,
const char *text);
4445 NK_INTERN int nk_str_match_star(
int c,
const char *regexp,
const char *text);
4446 NK_INTERN int nk_is_lower(
int c) {
return (c >=
'a' && c <=
'z') || (c >= 0xE0 && c <= 0xFF);}
4447 NK_INTERN int nk_is_upper(
int c){
return (c >=
'A' && c <=
'Z') || (c >= 0xC0 && c <= 0xDF);}
4448 NK_INTERN int nk_to_upper(
int c) {
return (c >=
'a' && c <=
'z') ? (c - (
'a' -
'A')) : c;}
4449 NK_INTERN int nk_to_lower(
int c) {
return (c >=
'A' && c <=
'Z') ? (c - (
'a' +
'A')) : c;}
4452 nk_memcopy(
void *dst0,
const void *src0, nk_size length)
4455 char *dst = (
char*)dst0;
4456 const char *src = (
const char*)src0;
4457 if (length == 0 || dst == src)
4461 #define nk_wsize sizeof(nk_word)
4462 #define nk_wmask (nk_wsize-1)
4463 #define NK_TLOOP(s) if (t) NK_TLOOP1(s)
4464 #define NK_TLOOP1(s) do { s; } while (--t)
4468 if ((t | (nk_ptr)dst) & nk_wmask) {
4469 if ((t ^ (nk_ptr)dst) & nk_wmask || length < nk_wsize)
4472 t = nk_wsize - (t & nk_wmask);
4474 NK_TLOOP1(*dst++ = *src++);
4476 t = length / nk_wsize;
4477 NK_TLOOP(*(nk_word*)(
void*)dst = *(
const nk_word*)(
const void*)src;
4478 src += nk_wsize; dst += nk_wsize);
4479 t = length & nk_wmask;
4480 NK_TLOOP(*dst++ = *src++);
4485 if ((t | (nk_ptr)dst) & nk_wmask) {
4486 if ((t ^ (nk_ptr)dst) & nk_wmask || length <= nk_wsize)
4491 NK_TLOOP1(*--dst = *--src);
4493 t = length / nk_wsize;
4494 NK_TLOOP(src -= nk_wsize; dst -= nk_wsize;
4495 *(nk_word*)(
void*)dst = *(
const nk_word*)(
const void*)src);
4496 t = length & nk_wmask;
4497 NK_TLOOP(*--dst = *--src);
4509 nk_memset(
void *ptr,
int c0, nk_size size)
4511 #define nk_word unsigned
4512 #define nk_wsize sizeof(nk_word)
4513 #define nk_wmask (nk_wsize - 1)
4514 nk_byte *dst = (nk_byte*)ptr;
4518 if ((c = (nk_byte)c0) != 0) {
4520 if (
sizeof(
unsigned int) > 2)
4525 dst = (nk_byte*)ptr;
4526 if (size < 3 * nk_wsize) {
4527 while (size--) *dst++ = (
nk_byte)c0;
4541 t = size / nk_wsize;
4543 *(nk_word*)((
void*)dst) = c;
4548 t = (size & nk_wmask);
4561 nk_zero(
void *ptr, nk_size size)
4564 NK_MEMSET(ptr, 0, size);
4572 while (str && *str++ !=
'\0') siz++;
4577 nk_strtoi(
const char *str,
const char **endptr)
4580 const char *p = str;
4587 while (*p ==
' ') p++;
4592 while (*p && *p >=
'0' && *p <=
'9') {
4593 value = value * 10 + (
int) (*p -
'0');
4602 nk_strtod(
const char *str,
const char **endptr)
4606 const char *p = str;
4614 while (*p ==
' ') p++;
4620 while (*p && *p !=
'.' && *p !=
'e') {
4621 value = value * 10.0 + (double) (*p -
'0');
4627 for(m = 0.1; *p && *p !=
'e'; p++ ) {
4628 value = value + (double) (*p -
'0') *
m;
4638 }
else if (*p ==
'+') {
4643 for (pow = 0; *p; p++)
4644 pow = pow * 10 + (
int) (*p -
'0');
4646 for (m = 1.0, i = 0; i < pow; i++)
4653 number = value * neg;
4660 nk_strtof(
const char *str,
const char **endptr)
4663 double double_value;
4664 double_value = NK_STRTOD(str, endptr);
4665 float_value = (float)double_value;
4678 if (c1 <= 'Z' && c1 >=
'A') {
4682 if (c2 <= 'Z' && c2 >=
'A') {
4686 return ((d >= 0) << 1) - 1;
4693 nk_stricmpn(
const char *s1,
const char *s2,
int n)
4704 if (c1 <= 'Z' && c1 >=
'A') {
4708 if (c2 <= 'Z' && c2 >=
'A') {
4712 return ((d >= 0) << 1) - 1;
4719 nk_str_match_here(
const char *regexp,
const char *text)
4721 if (regexp[0] ==
'\0')
4723 if (regexp[1] ==
'*')
4724 return nk_str_match_star(regexp[0], regexp+2, text);
4725 if (regexp[0] ==
'$' && regexp[1] ==
'\0')
4726 return *text ==
'\0';
4727 if (*text!=
'\0' && (regexp[0]==
'.' || regexp[0]==*text))
4728 return nk_str_match_here(regexp+1, text+1);
4733 nk_str_match_star(
int c,
const char *regexp,
const char *text)
4736 if (nk_str_match_here(regexp, text))
4738 }
while (*text !=
'\0' && (*text++ == c || c ==
'.'));
4751 if (regexp[0] ==
'^')
4752 return nk_str_match_here(regexp+1, text);
4754 if (nk_str_match_here(regexp, text))
4756 }
while (*text++ !=
'\0');
4762 const char *pattern,
int *out_score)
4770 #define NK_ADJACENCY_BONUS 5
4772 #define NK_SEPARATOR_BONUS 10
4774 #define NK_CAMEL_BONUS 10
4776 #define NK_LEADING_LETTER_PENALTY (-3)
4778 #define NK_MAX_LEADING_LETTER_PENALTY (-9)
4780 #define NK_UNMATCHED_LETTER_PENALTY (-1)
4784 char const * pattern_iter = pattern;
4792 char const * best_letter = 0;
4793 int best_letter_score = 0;
4798 if (!str || !str_len || !pattern)
return 0;
4799 while (str_iter < str_len)
4801 const char pattern_letter = *pattern_iter;
4802 const char str_letter = str[str_iter];
4804 int next_match = *pattern_iter !=
'\0' &&
4805 nk_to_lower(pattern_letter) == nk_to_lower(str_letter);
4806 int rematch = best_letter && nk_to_upper(*best_letter) == nk_to_upper(str_letter);
4808 int advanced = next_match && best_letter;
4809 int pattern_repeat = best_letter && *pattern_iter !=
'\0';
4810 pattern_repeat = pattern_repeat &&
4811 nk_to_lower(*best_letter) == nk_to_lower(pattern_letter);
4813 if (advanced || pattern_repeat) {
4814 score += best_letter_score;
4816 best_letter_score = 0;
4819 if (next_match || rematch)
4823 if (pattern_iter == pattern) {
4824 int count = (
int)(&str[str_iter] - str);
4825 int penalty = NK_LEADING_LETTER_PENALTY * count;
4826 if (penalty < NK_MAX_LEADING_LETTER_PENALTY)
4827 penalty = NK_MAX_LEADING_LETTER_PENALTY;
4834 new_score += NK_ADJACENCY_BONUS;
4838 new_score += NK_SEPARATOR_BONUS;
4841 if (prev_lower && nk_is_upper(str_letter))
4842 new_score += NK_CAMEL_BONUS;
4849 if (new_score >= best_letter_score) {
4851 if (best_letter != 0)
4852 score += NK_UNMATCHED_LETTER_PENALTY;
4854 best_letter = &str[str_iter];
4855 best_letter_score = new_score;
4859 score += NK_UNMATCHED_LETTER_PENALTY;
4864 prev_lower = nk_is_lower(str_letter) != 0;
4865 prev_separator = str_letter ==
'_' || str_letter ==
' ';
4872 score += best_letter_score;
4875 if (*pattern_iter !=
'\0')
4888 nk_string_float_limit(
char *
string,
int prec)
4898 if (dot == (prec+1)) {
4905 return (
int)(c -
string);
4909 nk_pow(
double x,
int n)
4914 n = (plus) ? n : -n;
4921 return plus ? r : 1.0 / r;
4925 nk_ifloord(
double x)
4927 x = (double)((
int)x - ((x < 0.0) ? 1 : 0));
4934 x = (float)((
int)x - ((x < 0.0f) ? 1 : 0));
4946 float r = x - (float)t;
4947 return (r > 0.0f) ? t+1: t;
4958 neg = (n < 0) ? 1 : 0;
4959 ret = (neg) ? (
int)-n : (
int)n;
4960 while ((ret / 10) > 0) {
4964 if (neg) exp = -exp;
4969 nk_strrev_ascii(
char *s)
4975 for (; i < end; ++i) {
4977 s[i] = s[len - 1 - i];
4983 nk_itoa(
char *s,
long n)
4996 s[i++] = (char)(
'0' + (n % 10));
5008 nk_dtoa(
char *s,
double n)
5011 int digit = 0, m = 0, m1 = 0;
5019 s[0] =
'0'; s[1] =
'\0';
5028 useExp = (m >= 14 || (neg && m >= 9) || m <= -9);
5029 if (neg) *(c++) =
'-';
5035 n = n / (double)nk_pow(10.0, m);
5044 while (n > NK_FLOAT_PRECISION || m >= 0) {
5045 double weight = nk_pow(10.0, m);
5047 double t = (double)n / weight;
5048 digit = nk_ifloord(t);
5049 n -= ((double)digit * weight);
5050 *(c++) = (
char)(
'0' + (char)digit);
5052 if (m == 0 && n > 0)
5069 *(c++) = (
char)(
'0' + (char)(m1 % 10));
5074 for (i = 0, j = m-1; i<j; i++, j--) {
5086 #ifdef NK_INCLUDE_STANDARD_VARARGS
5087 #ifndef NK_INCLUDE_STANDARD_IO
5089 nk_vsnprintf(
char *buf,
int buf_size,
const char *fmt, va_list args)
5094 NK_ARG_TYPE_DEFAULT,
5098 NK_ARG_FLAG_LEFT = 0x01,
5099 NK_ARG_FLAG_PLUS = 0x02,
5100 NK_ARG_FLAG_SPACE = 0x04,
5101 NK_ARG_FLAG_NUM = 0x10,
5102 NK_ARG_FLAG_ZERO = 0x20
5106 enum nk_arg_type arg_type = NK_ARG_TYPE_DEFAULT;
5107 int precision = NK_DEFAULT;
5108 int width = NK_DEFAULT;
5113 const char *iter = fmt;
5116 NK_ASSERT(buf_size);
5117 if (!buf || !buf_size || !fmt)
return 0;
5118 for (iter = fmt; *iter && len < buf_size; iter++) {
5120 while (*iter && (*iter !=
'%') && (len < buf_size))
5121 buf[len++] = *iter++;
5122 if (!(*iter) || len >= buf_size)
break;
5127 if (*iter ==
'-') flag |= NK_ARG_FLAG_LEFT;
5128 else if (*iter ==
'+') flag |= NK_ARG_FLAG_PLUS;
5129 else if (*iter ==
' ') flag |= NK_ARG_FLAG_SPACE;
5130 else if (*iter ==
'#') flag |= NK_ARG_FLAG_NUM;
5131 else if (*iter ==
'0') flag |= NK_ARG_FLAG_ZERO;
5138 if (*iter >=
'1' && *iter <=
'9') {
5144 }
else if (*iter ==
'*') {
5145 width = va_arg(args,
int);
5150 precision = NK_DEFAULT;
5154 precision = va_arg(args,
int);
5167 if (*(iter+1) ==
'h') {
5168 arg_type = NK_ARG_TYPE_CHAR;
5170 }
else arg_type = NK_ARG_TYPE_SHORT;
5172 }
else if (*iter ==
'l') {
5173 arg_type = NK_ARG_TYPE_LONG;
5175 }
else arg_type = NK_ARG_TYPE_DEFAULT;
5179 NK_ASSERT(arg_type == NK_ARG_TYPE_DEFAULT);
5180 NK_ASSERT(precision == NK_DEFAULT);
5181 NK_ASSERT(width == NK_DEFAULT);
5184 }
else if (*iter ==
's') {
5186 const char *str = va_arg(args,
const char*);
5187 NK_ASSERT(str != buf &&
"buffer and argument are not allowed to overlap!");
5188 NK_ASSERT(arg_type == NK_ARG_TYPE_DEFAULT);
5189 NK_ASSERT(precision == NK_DEFAULT);
5190 NK_ASSERT(width == NK_DEFAULT);
5191 if (str == buf)
return -1;
5192 while (str && *str && len < buf_size)
5193 buf[len++] = *str++;
5194 }
else if (*iter ==
'n') {
5196 signed int *n = va_arg(args,
int*);
5197 NK_ASSERT(arg_type == NK_ARG_TYPE_DEFAULT);
5198 NK_ASSERT(precision == NK_DEFAULT);
5199 NK_ASSERT(width == NK_DEFAULT);
5201 }
else if (*iter ==
'c' || *iter ==
'i' || *iter ==
'd') {
5204 const char *num_iter;
5205 int num_len, num_print, padding;
5206 int cur_precision =
NK_MAX(precision, 1);
5207 int cur_width =
NK_MAX(width, 0);
5210 if (arg_type == NK_ARG_TYPE_CHAR)
5211 value = (
signed char)va_arg(args,
int);
5212 else if (arg_type == NK_ARG_TYPE_SHORT)
5213 value = (
signed short)va_arg(args,
int);
5214 else if (arg_type == NK_ARG_TYPE_LONG)
5215 value = va_arg(args,
signed long);
5216 else if (*iter ==
'c')
5217 value = (
unsigned char)va_arg(args,
int);
5218 else value = va_arg(args,
signed int);
5221 nk_itoa(number_buffer, value);
5223 padding =
NK_MAX(cur_width -
NK_MAX(cur_precision, num_len), 0);
5224 if ((flag & NK_ARG_FLAG_PLUS) || (flag & NK_ARG_FLAG_SPACE))
5225 padding =
NK_MAX(padding-1, 0);
5228 if (!(flag & NK_ARG_FLAG_LEFT)) {
5229 while (padding-- > 0 && (len < buf_size)) {
5230 if ((flag & NK_ARG_FLAG_ZERO) && (precision == NK_DEFAULT))
5232 else buf[len++] =
' ';
5237 if ((flag & NK_ARG_FLAG_PLUS) && value >= 0 && len < buf_size)
5239 else if ((flag & NK_ARG_FLAG_SPACE) && value >= 0 && len < buf_size)
5243 num_print =
NK_MAX(cur_precision, num_len);
5244 while (precision && (num_print > num_len) && (len < buf_size)) {
5250 num_iter = number_buffer;
5251 while (precision && *num_iter && len < buf_size)
5252 buf[len++] = *num_iter++;
5255 if (flag & NK_ARG_FLAG_LEFT) {
5256 while ((padding-- > 0) && (len < buf_size))
5259 }
else if (*iter ==
'o' || *iter ==
'x' || *iter ==
'X' || *iter ==
'u') {
5261 unsigned long value = 0;
5262 int num_len = 0, num_print, padding = 0;
5263 int cur_precision =
NK_MAX(precision, 1);
5264 int cur_width =
NK_MAX(width, 0);
5265 unsigned int base = (*iter ==
'o') ? 8: (*iter ==
'u')? 10: 16;
5268 const char *upper_output_format =
"0123456789ABCDEF";
5269 const char *lower_output_format =
"0123456789abcdef";
5270 const char *output_format = (*iter ==
'x') ?
5271 lower_output_format: upper_output_format;
5274 if (arg_type == NK_ARG_TYPE_CHAR)
5275 value = (
unsigned char)va_arg(args,
int);
5276 else if (arg_type == NK_ARG_TYPE_SHORT)
5277 value = (
unsigned short)va_arg(args,
int);
5278 else if (arg_type == NK_ARG_TYPE_LONG)
5279 value = va_arg(args,
unsigned long);
5280 else value = va_arg(args,
unsigned int);
5284 int digit = output_format[value % base];
5286 number_buffer[num_len++] = (char)digit;
5288 }
while (value > 0);
5290 num_print =
NK_MAX(cur_precision, num_len);
5291 padding =
NK_MAX(cur_width -
NK_MAX(cur_precision, num_len), 0);
5292 if (flag & NK_ARG_FLAG_NUM)
5293 padding =
NK_MAX(padding-1, 0);
5296 if (!(flag & NK_ARG_FLAG_LEFT)) {
5297 while ((padding-- > 0) && (len < buf_size)) {
5298 if ((flag & NK_ARG_FLAG_ZERO) && (precision == NK_DEFAULT))
5300 else buf[len++] =
' ';
5305 if (num_print && (flag & NK_ARG_FLAG_NUM)) {
5306 if ((*iter ==
'o') && (len < buf_size)) {
5308 }
else if ((*iter ==
'x') && ((len+1) < buf_size)) {
5311 }
else if ((*iter ==
'X') && ((len+1) < buf_size)) {
5316 while (precision && (num_print > num_len) && (len < buf_size)) {
5322 while (num_len > 0) {
5323 if (precision && (len < buf_size))
5324 buf[len++] = number_buffer[num_len-1];
5329 if (flag & NK_ARG_FLAG_LEFT) {
5330 while ((padding-- > 0) && (len < buf_size))
5333 }
else if (*iter ==
'f') {
5335 const char *num_iter;
5336 int cur_precision = (precision < 0) ? 6: precision;
5337 int prefix, cur_width =
NK_MAX(width, 0);
5338 double value = va_arg(args,
double);
5339 int num_len = 0, frac_len = 0, dot = 0;
5342 NK_ASSERT(arg_type == NK_ARG_TYPE_DEFAULT);
5343 NK_DTOA(number_buffer, value);
5347 num_iter = number_buffer;
5348 while (*num_iter && *num_iter !=
'.')
5351 prefix = (*num_iter ==
'.')?(
int)(num_iter - number_buffer)+1:0;
5352 padding =
NK_MAX(cur_width - (prefix +
NK_MIN(cur_precision, num_len - prefix)) , 0);
5353 if ((flag & NK_ARG_FLAG_PLUS) || (flag & NK_ARG_FLAG_SPACE))
5354 padding =
NK_MAX(padding-1, 0);
5357 if (!(flag & NK_ARG_FLAG_LEFT)) {
5358 while (padding-- > 0 && (len < buf_size)) {
5359 if (flag & NK_ARG_FLAG_ZERO)
5361 else buf[len++] =
' ';
5366 num_iter = number_buffer;
5367 if ((flag & NK_ARG_FLAG_PLUS) && (value >= 0) && (len < buf_size))
5369 else if ((flag & NK_ARG_FLAG_SPACE) && (value >= 0) && (len < buf_size))
5372 if (dot) frac_len++;
5374 buf[len++] = *num_iter;
5375 if (*num_iter ==
'.') dot = 1;
5376 if (frac_len >= cur_precision)
break;
5381 while (frac_len < cur_precision) {
5382 if (!dot && len < buf_size) {
5392 if (flag & NK_ARG_FLAG_LEFT) {
5393 while ((padding-- > 0) && (len < buf_size))
5398 NK_ASSERT(0 &&
"specifier is not supported!");
5402 buf[(len >= buf_size)?(buf_size-1):len] = 0;
5403 result = (len >= buf_size)?-1:len;
5409 nk_strfmt(
char *buf,
int buf_size,
const char *fmt, va_list args)
5413 NK_ASSERT(buf_size);
5414 if (!buf || !buf_size || !fmt)
return 0;
5415 #ifdef NK_INCLUDE_STANDARD_IO
5416 result = NK_VSNPRINTF(buf, (nk_size)buf_size, fmt, args);
5417 result = (result >= buf_size) ? -1: result;
5418 buf[buf_size-1] = 0;
5420 result = nk_vsnprintf(buf, buf_size, fmt, args);
5430 #define NK_ROTL(x,r) ((x) << (r) | ((x) >> (32 - r)))
5431 union {
const nk_uint *i;
const nk_byte *b;} conv = {0};
5432 const nk_byte *data = (
const nk_byte*)key;
5433 const int nblocks = len/4;
5435 const nk_uint c1 = 0xcc9e2d51;
5436 const nk_uint c2 = 0x1b873593;
5437 const nk_byte *tail;
5438 const nk_uint *blocks;
5444 conv.b = (data + nblocks*4);
5445 blocks = (
const nk_uint*)conv.i;
5446 for (i = -nblocks; i; ++i) {
5449 k1 = NK_ROTL(k1,15);
5453 h1 = NK_ROTL(h1,13);
5454 h1 = h1*5+0xe6546b64;
5458 tail = (
const nk_byte*)(data + nblocks*4);
5461 case 3: k1 ^= (
nk_uint)(tail[2] << 16);
5462 case 2: k1 ^= (
nk_uint)(tail[1] << 8u);
5463 case 1: k1 ^= tail[0];
5465 k1 = NK_ROTL(k1,15);
5484 #ifdef NK_INCLUDE_STANDARD_IO
5486 nk_file_load(
const char* path, nk_size* siz,
struct nk_allocator *alloc)
5495 if (!path || !siz || !alloc)
5498 fd = fopen(path,
"rb");
5514 *siz = (
nk_size)fread(buf, *siz, 1, fd);
5528 nk_parse_hex(
const char *p,
int length)
5532 while (len < length) {
5534 if (p[len] >=
'a' && p[len] <=
'f')
5535 i += ((p[len] -
'a') + 10);
5536 else if (p[len] >=
'A' && p[len] <=
'F')
5537 i += ((p[len] -
'A') + 10);
5538 else i += (p[len] -
'0');
5559 const char *c = rgb;
5561 col.
r = (
nk_byte)nk_parse_hex(c, 2);
5562 col.g = (
nk_byte)nk_parse_hex(c+2, 2);
5563 col.b = (
nk_byte)nk_parse_hex(c+4, 2);
5572 const char *c = rgb;
5574 col.
r = (
nk_byte)nk_parse_hex(c, 2);
5575 col.g = (
nk_byte)nk_parse_hex(c+2, 2);
5576 col.b = (
nk_byte)nk_parse_hex(c+4, 2);
5577 col.a = (
nk_byte)nk_parse_hex(c+6, 2);
5584 #define NK_TO_HEX(i) ((i) <= 9 ? '0' + (i): 'A' - 10 + (i))
5585 output[0] = (char)NK_TO_HEX((col.
r & 0xF0) >> 4);
5586 output[1] = (char)NK_TO_HEX((col.
r & 0x0F));
5587 output[2] = (char)NK_TO_HEX((col.
g & 0xF0) >> 4);
5588 output[3] = (char)NK_TO_HEX((col.
g & 0x0F));
5589 output[4] = (char)NK_TO_HEX((col.
b & 0xF0) >> 4);
5590 output[5] = (char)NK_TO_HEX((col.
b & 0x0F));
5591 output[6] = (char)NK_TO_HEX((col.
a & 0xF0) >> 4);
5592 output[7] = (char)NK_TO_HEX((col.
a & 0x0F));
5600 #define NK_TO_HEX(i) ((i) <= 9 ? '0' + (i): 'A' - 10 + (i))
5601 output[0] = (char)NK_TO_HEX((col.
r & 0xF0) >> 4);
5602 output[1] = (char)NK_TO_HEX((col.
r & 0x0F));
5603 output[2] = (char)NK_TO_HEX((col.
g & 0xF0) >> 4);
5604 output[3] = (char)NK_TO_HEX((col.
g & 0x0F));
5605 output[4] = (char)NK_TO_HEX((col.
b & 0xF0) >> 4);
5606 output[5] = (char)NK_TO_HEX((col.
b & 0x0F));
5614 return nk_rgba(c[0], c[1], c[2], c[3]);
5620 return nk_rgba(c[0], c[1], c[2], c[3]);
5637 return nk_rgb(c[0], c[1], c[2]);
5643 return nk_rgb(c[0], c[1], c[2]);
5650 ret.
r = (in & 0xFF);
5651 ret.g = ((in >> 8) & 0xFF);
5652 ret.b = ((in >> 16) & 0xFF);
5653 ret.a = (
nk_byte)((in >> 24) & 0xFF);
5671 return nk_rgba_f(c[0], c[1], c[2], c[3]);
5692 nk_hsv(int h, int s, int v)
5700 return nk_hsv(c[0], c[1], c[2]);
5706 return nk_hsv(c[0], c[1], c[2]);
5710 nk_hsv_f(float h, float s, float v)
5722 nk_hsva(int h, int s, int v, int
a)
5724 float hf = ((float)
NK_CLAMP(0, h, 255)) / 255.0f;
5725 float sf = ((float)
NK_CLAMP(0, s, 255)) / 255.0f;
5726 float vf = ((float)
NK_CLAMP(0, v, 255)) / 255.0f;
5727 float af = ((float)
NK_CLAMP(0,
a, 255)) / 255.0f;
5734 return nk_hsva(c[0], c[1], c[2], c[3]);
5740 return nk_hsva(c[0], c[1], c[2], c[3]);
5744 nk_hsva_f(float h, float s, float v, float
a)
5751 out.
r = v; out.
g = v; out.
b = v;
5755 h = h / (60.0f/360.0f);
5759 q = v * (1.0f - (s * f));
5760 t = v * (1.0f - s * (1.0f - f));
5763 case 0:
default: out.r = v; out.g = t; out.b = p;
break;
5764 case 1: out.r = q; out.g = v; out.b = p;
break;
5765 case 2: out.r = p; out.g = v; out.b = t;
break;
5766 case 3: out.r = p; out.g = q; out.b = v;
break;
5767 case 4: out.r = t; out.g = p; out.b = v;
break;
5768 case 5: out.r = v; out.g = p; out.b = q;
break;
5776 return nk_hsva_f(c[0], c[1], c[2], c[3]);
5783 out |= ((nk_uint)in.
g << 8);
5793 *r = (float)in.
r * s;
5794 *g = (
float)in.
g * s;
5795 *b = (float)in.
b * s;
5796 *a = (
float)in.
a * s;
5809 *r = (double)in.
r * s;
5810 *g = (
double)in.
g * s;
5811 *b = (double)in.
b * s;
5812 *a = (
double)in.
a * s;
5837 float *out_v,
float *out_a,
struct nk_color in)
5845 const float t =
g; g =
b; b = t;
5849 const float t =
r; r =
g; g = t;
5852 chroma = r - ((g <
b) ? g: b);
5853 *out_h =
NK_ABS(K + (g - b)/(6.0f * chroma + 1e-20f));
5854 *out_s = chroma / (r + 1e-20f);
5856 *out_a = (float)in.
a / 255.0f;
5871 *out_h = (
nk_byte)(h * 255.0f);
5872 *out_s = (
nk_byte)(s * 255.0f);
5873 *out_v = (
nk_byte)(v * 255.0f);
5874 *out_a = (
nk_byte)(a * 255.0f);
5947 nk_handle handle = {0};
5965 nk_zero(&s,
sizeof(s));
5968 s.region[0] = (
unsigned short)r.x;
5969 s.region[1] = (
unsigned short)r.y;
5970 s.region[2] = (
unsigned short)r.w;
5971 s.region[3] = (
unsigned short)r.h;
5979 nk_zero(&s,
sizeof(s));
5982 s.region[0] = (
unsigned short)r.x;
5983 s.region[1] = (
unsigned short)r.y;
5984 s.region[2] = (
unsigned short)r.w;
5985 s.region[3] = (
unsigned short)r.h;
5994 nk_zero(&s,
sizeof(s));
5997 s.region[0] = (
unsigned short)r.x;
5998 s.region[1] = (
unsigned short)r.y;
5999 s.region[2] = (
unsigned short)r.w;
6000 s.region[3] = (
unsigned short)r.h;
6008 nk_zero(&s,
sizeof(s));
6022 nk_zero(&s,
sizeof(s));
6037 nk_zero(&s,
sizeof(s));
6051 return !(img->
w == 0 && img->
h == 0);
6055 nk_unify(
struct nk_rect *clip,
const struct nk_rect *a,
float x0,
float y0,
6070 float pad_x,
float pad_y,
enum nk_heading direction)
6072 float w_half, h_half;
6077 r.
w = r.
w - 2 * pad_x;
6078 r.
h = r.
h - 2 * pad_y;
6083 w_half = r.
w / 2.0f;
6084 h_half = r.
h / 2.0f;
6086 if (direction ==
NK_UP) {
6090 }
else if (direction ==
NK_RIGHT) {
6092 result[1] =
nk_vec2(r.
x + r.
w, r.
y + h_half);
6094 }
else if (direction ==
NK_DOWN) {
6097 result[2] =
nk_vec2(r.
x + w_half, r.
y + r.
h);
6106 nk_text_clamp(
const struct nk_user_font *font,
const char *text,
6107 int text_len,
float space,
int *glyphs,
float *text_width,
6108 nk_rune *sep_list,
int sep_count)
6112 float last_width = 0;
6113 nk_rune unicode = 0;
6121 float sep_width = 0;
6122 sep_count =
NK_MAX(sep_count,0);
6125 while (glyph_len && (width < space) && (len < text_len)) {
6128 for (i = 0; i < sep_count; ++i) {
6129 if (unicode != sep_list[i])
continue;
6130 sep_width = last_width = width;
6135 if (i ==
NK_MAX(sep_count,0)){
6136 last_width = sep_width = width;
6140 glyph_len =
nk_utf_decode(&text[len], &unicode, text_len - len);
6143 if (len >= text_len) {
6145 *text_width = last_width;
6149 *text_width = sep_width;
6150 return (!sep_len) ? len: sep_len;
6154 enum {NK_DO_NOT_STOP_ON_NEW_LINE, NK_STOP_ON_NEW_LINE};
6157 const char *begin,
int byte_len,
float row_height,
const char **remaining,
6158 struct nk_vec2 *out_offset,
int *glyphs,
int op)
6160 float line_height = row_height;
6162 float line_width = 0.0f;
6166 nk_rune unicode = 0;
6168 if (!begin || byte_len <= 0 || !font)
6172 if (!glyph_len)
return text_size;
6173 glyph_width = font->width(font->userdata, font->height, begin, glyph_len);
6176 while ((text_len < byte_len) && glyph_len) {
6177 if (unicode ==
'\n') {
6178 text_size.
x =
NK_MAX(text_size.
x, line_width);
6179 text_size.
y += line_height;
6182 if (op == NK_STOP_ON_NEW_LINE)
6186 glyph_len =
nk_utf_decode(begin + text_len, &unicode, byte_len-text_len);
6190 if (unicode ==
'\r') {
6193 glyph_len =
nk_utf_decode(begin + text_len, &unicode, byte_len-text_len);
6197 *glyphs = *glyphs + 1;
6198 text_len += glyph_len;
6199 line_width += (float)glyph_width;
6200 glyph_len =
nk_utf_decode(begin + text_len, &unicode, byte_len-text_len);
6201 glyph_width = font->width(font->userdata, font->height, begin+text_len, glyph_len);
6205 if (text_size.
x < line_width)
6206 text_size.
x = line_width;
6208 *out_offset =
nk_vec2(line_width, text_size.
y + line_height);
6209 if (line_width > 0 || text_size.
y == 0.0f)
6210 text_size.
y += line_height;
6212 *remaining = begin+text_len;
6227 nk_utf_validate(nk_rune *u,
int i)
6231 if (!
NK_BETWEEN(*u, nk_utfmin[i], nk_utfmax[i]) ||
6234 for (i = 1; *u > nk_utfmax[i]; ++i);
6239 nk_utf_decode_byte(
char c,
int *i)
6243 for(*i = 0; *i < (
int)
NK_LEN(nk_utfmask); ++(*i)) {
6244 if (((nk_byte)c & nk_utfmask[*i]) == nk_utfbyte[*i])
6245 return (nk_byte)(c & ~nk_utfmask[*i]);
6253 int i, j, len, type=0;
6259 if (!c || !u)
return 0;
6260 if (!clen)
return 0;
6263 udecoded = nk_utf_decode_byte(c[0], &len);
6267 for (i = 1, j = 1; i < clen && j < len; ++i, ++j) {
6268 udecoded = (udecoded << 6) | nk_utf_decode_byte(c[i], &type);
6275 nk_utf_validate(u, len);
6280 nk_utf_encode_byte(nk_rune u,
int i)
6282 return (
char)((nk_utfbyte[i]) | ((nk_byte)u & ~nk_utfmask[i]));
6289 len = nk_utf_validate(&u, 0);
6293 for (i = len - 1; i != 0; --i) {
6294 c[i] = nk_utf_encode_byte(u, 0);
6297 c[0] = nk_utf_encode_byte(u, len);
6312 if (!str || !len)
return 0;
6317 while (glyph_len && src_len < len) {
6319 src_len = src_len + glyph_len;
6320 glyph_len =
nk_utf_decode(text + src_len, &unicode, text_len - src_len);
6326 nk_utf_at(
const char *buffer,
int length,
int index,
6327 nk_rune *unicode,
int *len)
6339 if (!buffer || !unicode || !len)
return 0;
6356 src_len = src_len + glyph_len;
6357 glyph_len =
nk_utf_decode(text + src_len, unicode, text_len - src_len);
6359 if (i != index)
return 0;
6360 return buffer + src_len;
6368 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
6369 NK_INTERN void* nk_malloc(nk_handle unused,
void *old,nk_size size)
6371 NK_INTERN void nk_mfree(nk_handle unused,
void *ptr)
6375 nk_buffer_init_default(
struct nk_buffer *buffer)
6379 alloc.
alloc = nk_malloc;
6380 alloc.
free = nk_mfree;
6387 nk_size initial_size)
6391 NK_ASSERT(initial_size);
6392 if (!b || !a || !initial_size)
return;
6394 nk_zero(b,
sizeof(*b));
6398 b->
size = initial_size;
6409 if (!b || !m || !size)
return;
6411 nk_zero(b,
sizeof(*b));
6419 nk_buffer_align(
void *unaligned, nk_size align, nk_size *alignment,
6429 *alignment = (
nk_size)((nk_byte*)memory - (nk_byte*)unaligned);
6438 *alignment = (
nk_size)((nk_byte*)unaligned - (nk_byte*)memory);
6449 nk_buffer_realloc(
struct nk_buffer *b, nk_size capacity, nk_size *size)
6462 if (!temp)
return 0;
6466 NK_MEMCPY(temp, b->
memory.
ptr, buffer_size);
6470 if (b->
size == buffer_size) {
6478 back_size = buffer_size - b->
size;
6479 dst =
nk_ptr_add(
void, temp, capacity - back_size);
6481 NK_MEMCPY(dst, src, back_size);
6482 b->
size = capacity - back_size;
6489 nk_size size, nk_size align)
6498 if (!b || !size)
return 0;
6505 memory = nk_buffer_align(unaligned, align, &alignment, type);
6522 capacity =
NK_MAX(capacity, nk_round_up_pow2((nk_uint)(b->
allocated + size)));
6530 memory = nk_buffer_align(unaligned, align, &alignment, type);
6535 else b->
size -= (size + alignment);
6543 const void *memory, nk_size size, nk_size align)
6545 void *mem = nk_buffer_alloc(b, type, size, align);
6547 NK_MEMCPY(mem, memory, size);
6554 if (!buffer)
return;
6565 if (!buffer)
return;
6610 if (!s || !b)
return;
6622 if (!buffer)
return 0;
6630 if (!buffer)
return 0;
6638 if (!buffer)
return 0;
6649 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
6651 nk_str_init_default(
struct nk_str *str)
6655 alloc.
alloc = nk_malloc;
6656 alloc.
free = nk_mfree;
6682 if (!s || !str || !len)
return 0;
6685 NK_MEMCPY(mem, str, (nk_size)len *
sizeof(
char));
6702 if (!str || !text || !len)
return 0;
6703 for (i = 0; i < len; ++i)
6717 if (!str || !text)
return 0;
6719 glyph_len = byte_len =
nk_utf_decode(text+byte_len, &unicode, 4);
6720 while (unicode !=
'\0' && glyph_len) {
6722 byte_len += glyph_len;
6737 if (!str || !text || !len)
return 0;
6738 for (i = 0; i < len; ++i) {
6740 if (!byte_len)
break;
6753 if (!str || !runes)
return 0;
6754 while (runes[i] !=
'\0') {
6773 NK_ASSERT(len >= 0);
6774 if (!s || !str || !len || (nk_size)pos > s->
buffer.
allocated)
return 0;
6787 NK_ASSERT(((
int)pos + (
int)len + ((
int)copylen - 1)) >= 0);
6788 NK_ASSERT(((
int)pos + ((
int)copylen - 1)) >= 0);
6791 for (i = 0; i < copylen; ++i) *dst-- = *src--;
6793 NK_MEMCPY(mem, str, (nk_size)len *
sizeof(
char));
6809 if (!str || !cstr || !len)
return 0;
6814 if (!begin)
return 0;
6839 if (!str || !text || !len)
return 0;
6840 for (i = 0; i < len; ++i)
6854 if (!str || !text)
return 0;
6856 glyph_len = byte_len =
nk_utf_decode(text+byte_len, &unicode, 4);
6857 while (unicode !=
'\0' && glyph_len) {
6859 byte_len += glyph_len;
6874 if (!str || !runes || !len)
return 0;
6875 for (i = 0; i < len; ++i) {
6877 if (!byte_len)
break;
6890 if (!str || !runes)
return 0;
6891 while (runes[i] !=
'\0') {
6903 NK_ASSERT(len >= 0);
6919 NK_ASSERT(len >= 0);
6920 if (!str || len < 0)
return;
6921 if (len >= str->
len) {
6926 index = str->
len - len;
6960 NK_ASSERT(s->
len >= pos + len);
6961 if (s->
len < pos + len)
6996 if (!str || !unicode || !len)
return 0;
7013 src_len = src_len + glyph_len;
7014 glyph_len =
nk_utf_decode(text + src_len, unicode, text_len - src_len);
7016 if (i != pos)
return 0;
7017 return text + src_len;
7041 if (!str || !unicode || !len)
return 0;
7058 src_len = src_len + glyph_len;
7059 glyph_len =
nk_utf_decode(text + src_len, unicode, text_len - src_len);
7061 if (i != pos)
return 0;
7062 return text + src_len;
7069 nk_rune unicode = 0;
7135 if (!cmdbuf || !buffer)
return;
7136 cmdbuf->
base = buffer;
7147 if (!buffer)
return;
7151 buffer->
clip = nk_null_rect;
7152 #ifdef NK_INCLUDE_COMMAND_USERDATA
7175 unaligned = (nk_byte*)cmd + size;
7177 alignment = (
nk_size)((nk_byte*)memory - (nk_byte*)unaligned);
7178 #ifdef NK_ZERO_COMMAND_MEMORY
7179 NK_MEMSET(cmd, 0, size + alignment);
7184 #ifdef NK_INCLUDE_COMMAND_USERDATA
7206 cmd->
x = (short)r.
x;
7207 cmd->
y = (
short)r.
y;
7208 cmd->
w = (
unsigned short)
NK_MAX(0, r.
w);
7209 cmd->
h = (
unsigned short)
NK_MAX(0, r.
h);
7214 float x1,
float y1,
float line_thickness,
struct nk_color c)
7223 cmd->
begin.
x = (short)x0;
7224 cmd->
begin.
y = (short)y0;
7225 cmd->
end.
x = (short)x1;
7226 cmd->
end.
y = (short)y1;
7232 float ctrl0x,
float ctrl0y,
float ctrl1x,
float ctrl1y,
7233 float bx,
float by,
float line_thickness,
struct nk_color col)
7237 if (!b || col.
a == 0)
return;
7243 cmd->
begin.
x = (short)ax;
7244 cmd->
begin.
y = (short)ay;
7245 cmd->
ctrl[0].
x = (short)ctrl0x;
7246 cmd->
ctrl[0].
y = (short)ctrl0y;
7247 cmd->
ctrl[1].
x = (short)ctrl1x;
7248 cmd->
ctrl[1].
y = (short)ctrl1y;
7249 cmd->
end.
x = (short)bx;
7250 cmd->
end.
y = (short)by;
7256 float rounding,
float line_thickness,
struct nk_color c)
7260 if (!b || c.
a == 0 || rect.
w == 0 || rect.
h == 0)
return;
7264 clip->
x, clip->
y, clip->
w, clip->
h))
return;
7270 cmd->
rounding = (
unsigned short)rounding;
7272 cmd->
x = (short)rect.
x;
7273 cmd->
y = (
short)rect.
y;
7274 cmd->
w = (
unsigned short)
NK_MAX(0, rect.
w);
7275 cmd->
h = (
unsigned short)
NK_MAX(0, rect.
h);
7285 if (!b || c.
a == 0 || rect.
w == 0 || rect.
h == 0)
return;
7289 clip->
x, clip->
y, clip->
w, clip->
h))
return;
7295 cmd->
rounding = (
unsigned short)rounding;
7296 cmd->
x = (short)rect.
x;
7297 cmd->
y = (
short)rect.
y;
7298 cmd->
w = (
unsigned short)
NK_MAX(0, rect.
w);
7299 cmd->
h = (
unsigned short)
NK_MAX(0, rect.
h);
7310 if (!b || rect.
w == 0 || rect.
h == 0)
return;
7314 clip->
x, clip->
y, clip->
w, clip->
h))
return;
7320 cmd->
x = (short)rect.
x;
7321 cmd->
y = (
short)rect.
y;
7322 cmd->
w = (
unsigned short)
NK_MAX(0, rect.
w);
7323 cmd->
h = (
unsigned short)
NK_MAX(0, rect.
h);
7332 float line_thickness,
struct nk_color c)
7335 if (!b || r.
w == 0 || r.
h == 0)
return;
7346 cmd->
x = (short)r.
x;
7347 cmd->
y = (
short)r.
y;
7348 cmd->
w = (
unsigned short)
NK_MAX(r.
w, 0);
7349 cmd->
h = (
unsigned short)
NK_MAX(r.
h, 0);
7358 if (!b || c.
a == 0 || r.
w == 0 || r.
h == 0)
return;
7368 cmd->
x = (short)r.
x;
7369 cmd->
y = (
short)r.
y;
7370 cmd->
w = (
unsigned short)
NK_MAX(r.
w, 0);
7371 cmd->
h = (
unsigned short)
NK_MAX(r.
h, 0);
7377 float a_min,
float a_max,
float line_thickness,
struct nk_color c)
7380 if (!b || c.
a == 0)
return;
7385 cmd->
cx = (short)cx;
7386 cmd->
cy = (short)cy;
7387 cmd->
r = (
unsigned short)radius;
7395 float a_min,
float a_max,
struct nk_color c)
7399 if (!b || c.
a == 0)
return;
7403 cmd->
cx = (short)cx;
7404 cmd->
cy = (short)cy;
7405 cmd->
r = (
unsigned short)radius;
7413 float y1,
float x2,
float y2,
float line_thickness,
struct nk_color c)
7417 if (!b || c.
a == 0)
return;
7420 if (!
NK_INBOX(x0, y0, clip->
x, clip->
y, clip->
w, clip->
h) &&
7421 !
NK_INBOX(x1, y1, clip->
x, clip->
y, clip->
w, clip->
h) &&
7430 cmd->
a.
x = (short)x0;
7431 cmd->
a.
y = (short)y0;
7432 cmd->
b.
x = (short)x1;
7433 cmd->
b.
y = (short)y1;
7434 cmd->
c.
x = (short)x2;
7435 cmd->
c.
y = (short)y2;
7441 float y1,
float x2,
float y2,
struct nk_color c)
7445 if (!b || c.
a == 0)
return;
7449 if (!
NK_INBOX(x0, y0, clip->
x, clip->
y, clip->
w, clip->
h) &&
7450 !
NK_INBOX(x1, y1, clip->
x, clip->
y, clip->
w, clip->
h) &&
7458 cmd->
a.
x = (short)x0;
7459 cmd->
a.
y = (short)y0;
7460 cmd->
b.
x = (short)x1;
7461 cmd->
b.
y = (short)y1;
7462 cmd->
c.
x = (short)x2;
7463 cmd->
c.
y = (short)y2;
7469 float line_thickness,
struct nk_color col)
7476 if (!b || col.
a == 0)
return;
7477 size =
sizeof(*cmd) +
sizeof(short) * 2 * (nk_size)point_count;
7481 cmd->line_thickness = (
unsigned short)line_thickness;
7482 cmd->point_count = (
unsigned short)point_count;
7483 for (i = 0; i < point_count; ++i) {
7484 cmd->
points[i].
x = (short)points[i*2];
7485 cmd->
points[i].
y = (short)points[i*2+1];
7498 if (!b || col.
a == 0)
return;
7499 size =
sizeof(*cmd) +
sizeof(short) * 2 * (nk_size)point_count;
7504 cmd->point_count = (
unsigned short)point_count;
7505 for (i = 0; i < point_count; ++i) {
7506 cmd->
points[i].
x = (short)points[i*2+0];
7507 cmd->
points[i].
y = (short)points[i*2+1];
7513 float line_thickness,
struct nk_color col)
7520 if (!b || col.
a == 0)
return;
7521 size =
sizeof(*cmd) +
sizeof(short) * 2 * (nk_size)point_count;
7525 cmd->point_count = (
unsigned short)point_count;
7526 cmd->line_thickness = (
unsigned short)line_thickness;
7527 for (i = 0; i < point_count; ++i) {
7528 cmd->
points[i].
x = (short)points[i*2];
7529 cmd->
points[i].
y = (short)points[i*2+1];
7549 cmd->
x = (short)r.
x;
7550 cmd->
y = (
short)r.
y;
7551 cmd->
w = (
unsigned short)
NK_MAX(0, r.
w);
7552 cmd->
h = (
unsigned short)
NK_MAX(0, r.
h);
7573 cmd->
x = (short)r.
x;
7574 cmd->
y = (
short)r.
y;
7575 cmd->
w = (
unsigned short)
NK_MAX(0, r.
w);
7576 cmd->
h = (
unsigned short)
NK_MAX(0, r.
h);
7583 const char *
string,
int length,
const struct nk_user_font *font,
7586 float text_width = 0;
7591 if (!b || !
string || !length || (bg.
a == 0 && fg.
a == 0))
return;
7600 if (text_width > r.
w){
7602 float txt_width = (float)text_width;
7603 length = nk_text_clamp(font,
string, length, r.
w, &glyphs, &txt_width, 0,0);
7606 if (!length)
return;
7610 cmd->
x = (short)r.
x;
7611 cmd->
y = (
short)r.
y;
7612 cmd->
w = (
unsigned short)r.
w;
7613 cmd->
h = (
unsigned short)r.
h;
7619 NK_MEMCPY(cmd->
string,
string, (nk_size)length);
7628 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
7630 nk_draw_list_init(
struct nk_draw_list *list)
7635 nk_zero(list,
sizeof(*list));
7636 for (i = 0; i <
NK_LEN(list->circle_vtx); ++i) {
7637 const float a = ((float)i / (
float)
NK_LEN(list->circle_vtx)) * 2 *
NK_PI;
7638 list->circle_vtx[i].x = (float)NK_COS(a);
7639 list->circle_vtx[i].y = (float)NK_SIN(a);
7650 NK_ASSERT(vertices);
7651 NK_ASSERT(elements);
7652 if (!canvas || !config || !cmds || !vertices || !elements)
7655 canvas->buffer = cmds;
7656 canvas->config = *
config;
7657 canvas->elements = elements;
7658 canvas->vertices = vertices;
7659 canvas->clip_rect = nk_null_rect;
7662 NK_API const struct nk_draw_command*
7663 nk__draw_list_begin(
const struct nk_draw_list *canvas,
const struct nk_buffer *buffer)
7667 const struct nk_draw_command *cmd;
7670 if (!buffer || !buffer->
size || !canvas->cmd_count)
7674 offset = buffer->
memory.
size - canvas->cmd_offset;
7675 cmd =
nk_ptr_add(
const struct nk_draw_command, memory, offset);
7679 NK_API const struct nk_draw_command*
7680 nk__draw_list_end(
const struct nk_draw_list *canvas,
const struct nk_buffer *buffer)
7685 const struct nk_draw_command *end;
7689 if (!buffer || !canvas)
7694 offset = size - canvas->cmd_offset;
7695 end =
nk_ptr_add(
const struct nk_draw_command, memory, offset);
7696 end -= (canvas->cmd_count-1);
7700 NK_API const struct nk_draw_command*
7701 nk__draw_list_next(
const struct nk_draw_command *cmd,
7702 const struct nk_buffer *buffer,
const struct nk_draw_list *canvas)
7704 const struct nk_draw_command *end;
7707 if (!cmd || !buffer || !canvas)
7710 end = nk__draw_list_end(canvas, buffer);
7711 if (cmd <= end)
return 0;
7716 nk_draw_list_clear(
struct nk_draw_list *list)
7727 list->element_count = 0;
7728 list->vertex_count = 0;
7729 list->cmd_offset = 0;
7730 list->cmd_count = 0;
7731 list->path_count = 0;
7734 list->clip_rect = nk_null_rect;
7738 nk_draw_list_alloc_path(
struct nk_draw_list *list,
int count)
7745 point_size * (nk_size)count, point_align);
7747 if (!points)
return 0;
7748 if (!list->path_offset) {
7750 list->path_offset = (
unsigned int)((nk_byte*)points - (nk_byte*)memory);
7752 list->path_count += (
unsigned int)count;
7757 nk_draw_list_path_last(struct nk_draw_list *list)
7761 NK_ASSERT(list->path_count);
7764 point += (list->path_count-1);
7769 nk_draw_list_push_command(
struct nk_draw_list *list,
struct nk_rect clip,
7773 NK_STORAGE const nk_size cmd_size =
sizeof(
struct nk_draw_command);
7774 struct nk_draw_command *cmd;
7777 cmd = (
struct nk_draw_command*)
7778 nk_buffer_alloc(list->buffer,
NK_BUFFER_BACK, cmd_size, cmd_align);
7781 if (!list->cmd_count) {
7785 list->cmd_offset = (
nk_size)(memory - (nk_byte*)cmd);
7788 cmd->elem_count = 0;
7789 cmd->clip_rect = clip;
7791 #ifdef NK_INCLUDE_COMMAND_USERDATA
7792 cmd->userdata = list->userdata;
7796 list->clip_rect = clip;
7801 nk_draw_list_command_last(
struct nk_draw_list *list)
7805 struct nk_draw_command *cmd;
7806 NK_ASSERT(list->cmd_count);
7810 cmd =
nk_ptr_add(
struct nk_draw_command, memory, size - list->cmd_offset);
7811 return (cmd - (list->cmd_count-1));
7815 nk_draw_list_add_clip(
struct nk_draw_list *list,
struct nk_rect rect)
7819 if (!list->cmd_count) {
7820 nk_draw_list_push_command(list, rect, list->config.null.texture);
7822 struct nk_draw_command *prev = nk_draw_list_command_last(list);
7823 if (prev->elem_count == 0)
7824 prev->clip_rect = rect;
7825 nk_draw_list_push_command(list, rect, prev->texture);
7830 nk_draw_list_push_image(
struct nk_draw_list *list, nk_handle texture)
7834 if (!list->cmd_count) {
7835 nk_draw_list_push_command(list, nk_null_rect, texture);
7837 struct nk_draw_command *prev = nk_draw_list_command_last(list);
7838 if (prev->elem_count == 0)
7840 else if (prev->texture.id != texture.
id)
7841 nk_draw_list_push_command(list, prev->clip_rect, texture);
7845 #ifdef NK_INCLUDE_COMMAND_USERDATA
7847 nk_draw_list_push_userdata(
struct nk_draw_list *list, nk_handle userdata)
7849 list->userdata = userdata;
7854 nk_draw_list_alloc_vertices(
struct nk_draw_list *list, nk_size count)
7858 if (!list)
return 0;
7860 list->config.vertex_size*count, list->config.vertex_alignment);
7862 list->vertex_count += (
unsigned int)count;
7867 nk_draw_list_alloc_elements(
struct nk_draw_list *list, nk_size count)
7870 struct nk_draw_command *cmd;
7872 NK_STORAGE const nk_size elem_size =
sizeof(nk_draw_index);
7874 if (!list)
return 0;
7876 ids = (nk_draw_index*)
7877 nk_buffer_alloc(list->elements,
NK_BUFFER_FRONT, elem_size*count, elem_align);
7879 cmd = nk_draw_list_command_last(list);
7880 list->element_count += (
unsigned int)count;
7881 cmd->elem_count += (
unsigned int)count;
7886 nk_draw_vertex_layout_element_is_end_of_layout(
7887 const struct nk_draw_vertex_layout_element *element)
7889 return (element->attribute == NK_VERTEX_ATTRIBUTE_COUNT ||
7890 element->format == NK_FORMAT_COUNT);
7894 nk_draw_vertex_color(
void *attribute,
const float *values,
7895 enum nk_draw_vertex_layout_format format)
7898 NK_ASSERT(format >= NK_FORMAT_COLOR_BEGIN);
7899 NK_ASSERT(format <= NK_FORMAT_COLOR_END);
7900 if (format < NK_FORMAT_COLOR_BEGIN || format > NK_FORMAT_COLOR_END)
return;
7903 default: NK_ASSERT(0 &&
"Invalid vertex layout color format");
break;
7904 case NK_FORMAT_R8G8B8A8:
7905 case NK_FORMAT_R8G8B8: {
7907 NK_MEMCPY(attribute, &col.
r,
sizeof(col));
7909 case NK_FORMAT_R16G15B16: {
7911 col[0] = (
nk_ushort)
NK_CLAMP(NK_USHORT_MIN, values[0] * NK_USHORT_MAX, NK_USHORT_MAX);
7912 col[1] = (
nk_ushort)
NK_CLAMP(NK_USHORT_MIN, values[1] * NK_USHORT_MAX, NK_USHORT_MAX);
7913 col[2] = (
nk_ushort)
NK_CLAMP(NK_USHORT_MIN, values[2] * NK_USHORT_MAX, NK_USHORT_MAX);
7914 NK_MEMCPY(attribute, col,
sizeof(col));
7916 case NK_FORMAT_R16G15B16A16: {
7918 col[0] = (
nk_ushort)
NK_CLAMP(NK_USHORT_MIN, values[0] * NK_USHORT_MAX, NK_USHORT_MAX);
7919 col[1] = (
nk_ushort)
NK_CLAMP(NK_USHORT_MIN, values[1] * NK_USHORT_MAX, NK_USHORT_MAX);
7920 col[2] = (
nk_ushort)
NK_CLAMP(NK_USHORT_MIN, values[2] * NK_USHORT_MAX, NK_USHORT_MAX);
7921 col[3] = (
nk_ushort)
NK_CLAMP(NK_USHORT_MIN, values[3] * NK_USHORT_MAX, NK_USHORT_MAX);
7922 NK_MEMCPY(attribute, col,
sizeof(col));
7924 case NK_FORMAT_R32G32B32: {
7926 col[0] = (
nk_uint)
NK_CLAMP(NK_UINT_MIN, values[0] * NK_UINT_MAX, NK_UINT_MAX);
7927 col[1] = (
nk_uint)
NK_CLAMP(NK_UINT_MIN, values[1] * NK_UINT_MAX, NK_UINT_MAX);
7928 col[2] = (
nk_uint)
NK_CLAMP(NK_UINT_MIN, values[2] * NK_UINT_MAX, NK_UINT_MAX);
7929 NK_MEMCPY(attribute, col,
sizeof(col));
7931 case NK_FORMAT_R32G32B32A32: {
7933 col[0] = (
nk_uint)
NK_CLAMP(NK_UINT_MIN, values[0] * NK_UINT_MAX, NK_UINT_MAX);
7934 col[1] = (
nk_uint)
NK_CLAMP(NK_UINT_MIN, values[1] * NK_UINT_MAX, NK_UINT_MAX);
7935 col[2] = (
nk_uint)
NK_CLAMP(NK_UINT_MIN, values[2] * NK_UINT_MAX, NK_UINT_MAX);
7936 col[3] = (
nk_uint)
NK_CLAMP(NK_UINT_MIN, values[3] * NK_UINT_MAX, NK_UINT_MAX);
7937 NK_MEMCPY(attribute, col,
sizeof(col));
7939 case NK_FORMAT_R32G32B32A32_FLOAT:
7940 NK_MEMCPY(attribute, values,
sizeof(
float)*4);
7942 case NK_FORMAT_R32G32B32A32_DOUBLE: {
7948 NK_MEMCPY(attribute, col,
sizeof(col));
7950 case NK_FORMAT_RGB32:
7951 case NK_FORMAT_RGBA32: {
7954 NK_MEMCPY(attribute, &color,
sizeof(color));
7960 nk_draw_vertex_element(
void *dst,
const float *values,
int value_count,
7961 enum nk_draw_vertex_layout_format format)
7964 void *attribute = dst;
7966 NK_ASSERT(format < NK_FORMAT_COLOR_BEGIN);
7967 if (format >= NK_FORMAT_COLOR_BEGIN && format <= NK_FORMAT_COLOR_END)
return;
7968 for (value_index = 0; value_index < value_count; ++value_index) {
7970 default: NK_ASSERT(0 &&
"invalid vertex layout format");
break;
7971 case NK_FORMAT_SCHAR: {
7972 char value = (char)
NK_CLAMP(NK_SCHAR_MIN, values[value_index], NK_SCHAR_MAX);
7973 NK_MEMCPY(attribute, &value,
sizeof(value));
7974 attribute = (
void*)((
char*)attribute +
sizeof(char));
7976 case NK_FORMAT_SSHORT: {
7977 nk_short value = (
nk_short)
NK_CLAMP(NK_SSHORT_MIN, values[value_index], NK_SSHORT_MAX);
7978 NK_MEMCPY(attribute, &value,
sizeof(value));
7979 attribute = (
void*)((
char*)attribute +
sizeof(
value));
7981 case NK_FORMAT_SINT: {
7982 nk_int value = (
nk_int)
NK_CLAMP(NK_SINT_MIN, values[value_index], NK_SINT_MAX);
7983 NK_MEMCPY(attribute, &value,
sizeof(value));
7984 attribute = (
void*)((
char*)attribute +
sizeof(
nk_int));
7986 case NK_FORMAT_UCHAR: {
7987 unsigned char value = (
unsigned char)
NK_CLAMP(NK_UCHAR_MIN, values[value_index], NK_UCHAR_MAX);
7988 NK_MEMCPY(attribute, &value,
sizeof(value));
7989 attribute = (
void*)((
char*)attribute +
sizeof(
unsigned char));
7991 case NK_FORMAT_USHORT: {
7992 nk_ushort value = (
nk_ushort)
NK_CLAMP(NK_USHORT_MIN, values[value_index], NK_USHORT_MAX);
7993 NK_MEMCPY(attribute, &value,
sizeof(value));
7994 attribute = (
void*)((
char*)attribute +
sizeof(
value));
7996 case NK_FORMAT_UINT: {
7997 nk_uint value = (
nk_uint)
NK_CLAMP(NK_UINT_MIN, values[value_index], NK_UINT_MAX);
7998 NK_MEMCPY(attribute, &value,
sizeof(value));
7999 attribute = (
void*)((
char*)attribute +
sizeof(
nk_uint));
8001 case NK_FORMAT_FLOAT:
8002 NK_MEMCPY(attribute, &values[value_index],
sizeof(values[value_index]));
8003 attribute = (
void*)((
char*)attribute +
sizeof(float));
8005 case NK_FORMAT_DOUBLE: {
8006 double value = (double)values[value_index];
8007 NK_MEMCPY(attribute, &value,
sizeof(value));
8008 attribute = (
void*)((
char*)attribute +
sizeof(double));
8018 void *result = (
void*)((
char*)dst + config->
vertex_size);
8019 const struct nk_draw_vertex_layout_element *elem_iter = config->
vertex_layout;
8020 while (!nk_draw_vertex_layout_element_is_end_of_layout(elem_iter)) {
8021 void *address = (
void*)((
char*)dst + elem_iter->offset);
8022 switch (elem_iter->attribute) {
8023 case NK_VERTEX_ATTRIBUTE_COUNT:
8024 default: NK_ASSERT(0 &&
"wrong element attribute");
8025 case NK_VERTEX_POSITION: nk_draw_vertex_element(address, &pos.
x, 2, elem_iter->format);
break;
8026 case NK_VERTEX_TEXCOORD: nk_draw_vertex_element(address, &uv.
x, 2, elem_iter->format);
break;
8027 case NK_VERTEX_COLOR: nk_draw_vertex_color(address, &color.
r, elem_iter->format);
break;
8035 nk_draw_list_stroke_poly_line(
struct nk_draw_list *list,
const struct nk_vec2 *points,
8036 const unsigned int points_count,
struct nk_color color,
enum nk_draw_list_stroke closed,
8044 if (!list || points_count < 2)
return;
8046 color.
a = (
nk_byte)((
float)color.
a * list->config.global_alpha);
8047 count = points_count;
8048 if (!closed) count = points_count-1;
8049 thick_line = thickness > 1.0f;
8051 #ifdef NK_INCLUDE_COMMAND_USERDATA
8052 nk_draw_list_push_userdata(list, list->userdata);
8055 color.
a = (
nk_byte)((
float)color.
a * list->config.global_alpha);
8062 const float AA_SIZE = 1.0f;
8068 nk_size vertex_offset;
8069 nk_size index = list->vertex_count;
8071 const nk_size idx_count = (thick_line) ? (count * 18) : (count * 12);
8072 const nk_size vtx_count = (thick_line) ? (points_count * 4): (points_count *3);
8074 void *vtx = nk_draw_list_alloc_vertices(list, vtx_count);
8075 nk_draw_index *ids = nk_draw_list_alloc_elements(list, idx_count);
8078 struct nk_vec2 *normals, *temp;
8079 if (!vtx || !ids)
return;
8082 vertex_offset = (
nk_size)((nk_byte*)vtx - (nk_byte*)list->vertices->memory.ptr);
8084 size = pnt_size * ((thick_line) ? 5 : 3) * points_count;
8087 if (!normals)
return;
8088 temp = normals + points_count;
8091 vtx = (
void*)((nk_byte*)list->vertices->memory.ptr + vertex_offset);
8094 for (i1 = 0; i1 < count; ++i1) {
8095 const nk_size i2 = ((i1 + 1) == points_count) ? 0 : (i1 + 1);
8102 len = nk_inv_sqrt(len);
8106 normals[i1].
x = diff.
y;
8107 normals[i1].
y = -diff.
x;
8111 normals[points_count-1] = normals[points_count-2];
8120 temp[(points_count-1) * 2 + 0] =
nk_vec2_add(points[points_count-1], d);
8121 temp[(points_count-1) * 2 + 1] =
nk_vec2_sub(points[points_count-1], d);
8126 for (i1 = 0; i1 < count; i1++) {
8129 nk_size i2 = ((i1 + 1) == points_count) ? 0 : (i1 + 1);
8130 nk_size idx2 = ((i1+1) == points_count) ? index: (idx1 + 3);
8134 dmr2 = dm.x * dm.x + dm.y* dm.y;
8135 if (dmr2 > 0.000001f) {
8136 float scale = 1.0f/dmr2;
8137 scale =
NK_MIN(100.0f, scale);
8145 ids[0] = (nk_draw_index)(idx2 + 0); ids[1] = (nk_draw_index)(idx1+0);
8146 ids[2] = (nk_draw_index)(idx1 + 2); ids[3] = (nk_draw_index)(idx1+2);
8147 ids[4] = (nk_draw_index)(idx2 + 2); ids[5] = (nk_draw_index)(idx2+0);
8148 ids[6] = (nk_draw_index)(idx2 + 1); ids[7] = (nk_draw_index)(idx1+1);
8149 ids[8] = (nk_draw_index)(idx1 + 0); ids[9] = (nk_draw_index)(idx1+0);
8150 ids[10]= (nk_draw_index)(idx2 + 0); ids[11]= (nk_draw_index)(idx2+1);
8156 for (i = 0; i < points_count; ++i) {
8157 const struct nk_vec2 uv = list->config.null.uv;
8158 vtx = nk_draw_vertex(vtx, &list->config, points[i], uv, col);
8159 vtx = nk_draw_vertex(vtx, &list->config, temp[i*2+0], uv, col_trans);
8160 vtx = nk_draw_vertex(vtx, &list->config, temp[i*2+1], uv, col_trans);
8164 const float half_inner_thickness = (thickness - AA_SIZE) * 0.5f;
8174 d1 =
nk_vec2_muls(normals[points_count-1], half_inner_thickness + AA_SIZE);
8175 d2 =
nk_vec2_muls(normals[points_count-1], half_inner_thickness);
8177 temp[(points_count-1)*4+0] =
nk_vec2_add(points[points_count-1], d1);
8178 temp[(points_count-1)*4+1] =
nk_vec2_add(points[points_count-1], d2);
8179 temp[(points_count-1)*4+2] =
nk_vec2_sub(points[points_count-1], d2);
8180 temp[(points_count-1)*4+3] =
nk_vec2_sub(points[points_count-1], d1);
8185 for (i1 = 0; i1 < count; ++i1) {
8187 const nk_size i2 = ((i1+1) == points_count) ? 0: (i1 + 1);
8188 nk_size idx2 = ((i1+1) == points_count) ? index: (idx1 + 4);
8192 float dmr2 = dm.
x * dm.
x + dm.
y* dm.
y;
8193 if (dmr2 > 0.000001f) {
8194 float scale = 1.0f/dmr2;
8195 scale =
NK_MIN(100.0f, scale);
8199 dm_out =
nk_vec2_muls(dm, ((half_inner_thickness) + AA_SIZE));
8207 ids[0] = (nk_draw_index)(idx2 + 1); ids[1] = (nk_draw_index)(idx1+1);
8208 ids[2] = (nk_draw_index)(idx1 + 2); ids[3] = (nk_draw_index)(idx1+2);
8209 ids[4] = (nk_draw_index)(idx2 + 2); ids[5] = (nk_draw_index)(idx2+1);
8210 ids[6] = (nk_draw_index)(idx2 + 1); ids[7] = (nk_draw_index)(idx1+1);
8211 ids[8] = (nk_draw_index)(idx1 + 0); ids[9] = (nk_draw_index)(idx1+0);
8212 ids[10]= (nk_draw_index)(idx2 + 0); ids[11] = (nk_draw_index)(idx2+1);
8213 ids[12]= (nk_draw_index)(idx2 + 2); ids[13] = (nk_draw_index)(idx1+2);
8214 ids[14]= (nk_draw_index)(idx1 + 3); ids[15] = (nk_draw_index)(idx1+3);
8215 ids[16]= (nk_draw_index)(idx2 + 3); ids[17] = (nk_draw_index)(idx2+2);
8221 for (i = 0; i < points_count; ++i) {
8222 const struct nk_vec2 uv = list->config.null.uv;
8223 vtx = nk_draw_vertex(vtx, &list->config, temp[i*4+0], uv, col_trans);
8224 vtx = nk_draw_vertex(vtx, &list->config, temp[i*4+1], uv, col);
8225 vtx = nk_draw_vertex(vtx, &list->config, temp[i*4+2], uv, col);
8226 vtx = nk_draw_vertex(vtx, &list->config, temp[i*4+3], uv, col_trans);
8234 nk_size idx = list->vertex_count;
8235 const nk_size idx_count = count * 6;
8236 const nk_size vtx_count = count * 4;
8237 void *vtx = nk_draw_list_alloc_vertices(list, vtx_count);
8238 nk_draw_index *ids = nk_draw_list_alloc_elements(list, idx_count);
8239 if (!vtx || !ids)
return;
8241 for (i1 = 0; i1 < count; ++i1) {
8243 const struct nk_vec2 uv = list->config.null.uv;
8244 const nk_size i2 = ((i1+1) == points_count) ? 0 : i1 + 1;
8245 const struct nk_vec2 p1 = points[i1];
8246 const struct nk_vec2 p2 = points[i2];
8253 len = nk_inv_sqrt(len);
8258 dx = diff.
x * (thickness * 0.5f);
8259 dy = diff.
y * (thickness * 0.5f);
8261 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(p1.
x + dy, p1.
y - dx), uv, col);
8262 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(p2.
x + dy, p2.
y - dx), uv, col);
8263 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(p2.
x - dy, p2.
y + dx), uv, col);
8264 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(p1.
x - dy, p1.
y + dx), uv, col);
8266 ids[0] = (nk_draw_index)(idx+0); ids[1] = (nk_draw_index)(idx+1);
8267 ids[2] = (nk_draw_index)(idx+2); ids[3] = (nk_draw_index)(idx+0);
8268 ids[4] = (nk_draw_index)(idx+2); ids[5] = (nk_draw_index)(idx+3);
8277 nk_draw_list_fill_poly_convex(
struct nk_draw_list *list,
8278 const struct nk_vec2 *points,
const unsigned int points_count,
8287 if (!list || points_count < 3)
return;
8289 #ifdef NK_INCLUDE_COMMAND_USERDATA
8290 nk_draw_list_push_userdata(list, list->userdata);
8293 color.
a = (
nk_byte)((
float)color.
a * list->config.global_alpha);
8303 const float AA_SIZE = 1.0f;
8304 nk_size vertex_offset = 0;
8305 nk_size index = list->vertex_count;
8307 const nk_size idx_count = (points_count-2)*3 + points_count*6;
8308 const nk_size vtx_count = (points_count*2);
8310 void *vtx = nk_draw_list_alloc_vertices(list, vtx_count);
8311 nk_draw_index *ids = nk_draw_list_alloc_elements(list, idx_count);
8315 unsigned int vtx_inner_idx = (
unsigned int)(index + 0);
8316 unsigned int vtx_outer_idx = (
unsigned int)(index + 1);
8317 if (!vtx || !ids)
return;
8320 vertex_offset = (
nk_size)((nk_byte*)vtx - (nk_byte*)list->vertices->memory.ptr);
8322 size = pnt_size * points_count;
8325 if (!normals)
return;
8326 vtx = (
void*)((nk_byte*)list->vertices->memory.ptr + vertex_offset);
8329 for (i = 2; i < points_count; i++) {
8330 ids[0] = (nk_draw_index)(vtx_inner_idx);
8331 ids[1] = (nk_draw_index)(vtx_inner_idx + ((i-1) << 1));
8332 ids[2] = (nk_draw_index)(vtx_inner_idx + (i << 1));
8337 for (i0 = points_count-1, i1 = 0; i1 < points_count; i0 = i1++) {
8338 struct nk_vec2 p0 = points[i0];
8339 struct nk_vec2 p1 = points[i1];
8345 len = nk_inv_sqrt(len);
8349 normals[i0].
x = diff.
y;
8350 normals[i0].
y = -diff.
x;
8354 for (i0 = points_count-1, i1 = 0; i1 < points_count; i0 = i1++) {
8355 const struct nk_vec2 uv = list->config.null.uv;
8356 struct nk_vec2 n0 = normals[i0];
8357 struct nk_vec2 n1 = normals[i1];
8359 float dmr2 = dm.
x*dm.
x + dm.
y*dm.
y;
8360 if (dmr2 > 0.000001f) {
8361 float scale = 1.0f / dmr2;
8362 scale =
NK_MIN(scale, 100.0f);
8368 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2_sub(points[i1], dm), uv, col);
8369 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2_add(points[i1], dm), uv, col_trans);
8372 ids[0] = (nk_draw_index)(vtx_inner_idx+(i1<<1));
8373 ids[1] = (nk_draw_index)(vtx_inner_idx+(i0<<1));
8374 ids[2] = (nk_draw_index)(vtx_outer_idx+(i0<<1));
8375 ids[3] = (nk_draw_index)(vtx_outer_idx+(i0<<1));
8376 ids[4] = (nk_draw_index)(vtx_outer_idx+(i1<<1));
8377 ids[5] = (nk_draw_index)(vtx_inner_idx+(i1<<1));
8384 nk_size index = list->vertex_count;
8385 const nk_size idx_count = (points_count-2)*3;
8386 const nk_size vtx_count = points_count;
8387 void *vtx = nk_draw_list_alloc_vertices(list, vtx_count);
8388 nk_draw_index *ids = nk_draw_list_alloc_elements(list, idx_count);
8390 if (!vtx || !ids)
return;
8391 for (i = 0; i < vtx_count; ++i)
8392 vtx = nk_draw_vertex(vtx, &list->config, points[i], list->config.null.uv, col);
8393 for (i = 2; i < points_count; ++i) {
8394 ids[0] = (nk_draw_index)index;
8395 ids[1] = (nk_draw_index)(index+ i - 1);
8396 ids[2] = (nk_draw_index)(index+i);
8403 nk_draw_list_path_clear(
struct nk_draw_list *list)
8408 list->path_count = 0;
8409 list->path_offset = 0;
8413 nk_draw_list_path_line_to(
struct nk_draw_list *list,
struct nk_vec2 pos)
8416 struct nk_draw_command *cmd = 0;
8419 if (!list->cmd_count)
8420 nk_draw_list_add_clip(list, nk_null_rect);
8422 cmd = nk_draw_list_command_last(list);
8423 if (cmd && cmd->texture.ptr != list->config.null.texture.ptr)
8424 nk_draw_list_push_image(list, list->config.null.texture);
8426 points = nk_draw_list_alloc_path(list, 1);
8427 if (!points)
return;
8432 nk_draw_list_path_arc_to_fast(
struct nk_draw_list *list,
struct nk_vec2 center,
8433 float radius,
int a_min,
int a_max)
8438 if (a_min <= a_max) {
8439 for (a = a_min; a <= a_max; a++) {
8441 const float x = center.
x + c.
x * radius;
8442 const float y = center.
y + c.
y * radius;
8443 nk_draw_list_path_line_to(list,
nk_vec2(x, y));
8449 nk_draw_list_path_arc_to(
struct nk_draw_list *list,
struct nk_vec2 center,
8450 float radius,
float a_min,
float a_max,
unsigned int segments)
8455 if (radius == 0.0f)
return;
8456 for (i = 0; i <= segments; ++i) {
8457 const float a = a_min + ((float)i / ((
float)segments) * (a_max - a_min));
8458 const float x = center.x + (
float)NK_COS(a) * radius;
8459 const float y = center.
y + (
float)NK_SIN(a) * radius;
8460 nk_draw_list_path_line_to(list,
nk_vec2(x,
y));
8465 nk_draw_list_path_rect_to(struct nk_draw_list *list, struct
nk_vec2 a,
8466 struct
nk_vec2 b,
float rounding)
8472 r =
NK_MIN(r, ((b.x-a.x) < 0) ? -(b.x-a.x): (b.x-a.x));
8473 r =
NK_MIN(r, ((b.y-a.y) < 0) ? -(b.y-a.y): (b.y-a.y));
8476 nk_draw_list_path_line_to(list, a);
8477 nk_draw_list_path_line_to(list,
nk_vec2(b.x,a.y));
8478 nk_draw_list_path_line_to(list, b);
8479 nk_draw_list_path_line_to(list,
nk_vec2(a.x,b.y));
8481 nk_draw_list_path_arc_to_fast(list,
nk_vec2(a.x + r, a.y + r), r, 6, 9);
8482 nk_draw_list_path_arc_to_fast(list,
nk_vec2(b.x - r, a.y + r), r, 9, 12);
8483 nk_draw_list_path_arc_to_fast(list,
nk_vec2(b.x - r, b.y - r), r, 0, 3);
8484 nk_draw_list_path_arc_to_fast(list,
nk_vec2(a.x + r, b.y - r), r, 3, 6);
8489 nk_draw_list_path_curve_to(
struct nk_draw_list *list,
struct nk_vec2 p2,
8493 unsigned int i_step;
8497 NK_ASSERT(list->path_count);
8498 if (!list || !list->path_count)
return;
8499 num_segments =
NK_MAX(num_segments, 1);
8501 p1 = nk_draw_list_path_last(list);
8502 t_step = 1.0f/(float)num_segments;
8503 for (i_step = 1; i_step <= num_segments; ++i_step) {
8504 float t = t_step * (float)i_step;
8509 float w4 = t * t *t;
8510 float x = w1 * p1.
x + w2 * p2.
x + w3 * p3.
x + w4 * p4.
x;
8511 float y = w1 * p1.
y + w2 * p2.
y + w3 * p3.
y + w4 * p4.
y;
8512 nk_draw_list_path_line_to(list,
nk_vec2(x,y));
8517 nk_draw_list_path_fill(
struct nk_draw_list *list,
struct nk_color color)
8523 nk_draw_list_fill_poly_convex(list, points, list->path_count, color, list->config.shape_AA);
8524 nk_draw_list_path_clear(list);
8528 nk_draw_list_path_stroke(
struct nk_draw_list *list,
struct nk_color color,
8529 enum nk_draw_list_stroke closed,
float thickness)
8535 nk_draw_list_stroke_poly_line(list, points, list->path_count, color,
8536 closed, thickness, list->config.line_AA);
8537 nk_draw_list_path_clear(list);
8541 nk_draw_list_stroke_line(
struct nk_draw_list *list,
struct nk_vec2 a,
8545 if (!list || !col.
a)
return;
8548 nk_draw_list_path_stroke(list, col, NK_STROKE_OPEN, thickness);
8552 nk_draw_list_fill_rect(
struct nk_draw_list *list,
struct nk_rect rect,
8553 struct nk_color col,
float rounding)
8556 if (!list || !col.
a)
return;
8557 nk_draw_list_path_rect_to(list,
nk_vec2(rect.
x + 0.5f, rect.
y + 0.5f),
8558 nk_vec2(rect.
x + rect.
w + 0.5f, rect.
y + rect.
h + 0.5f), rounding);
8559 nk_draw_list_path_fill(list, col);
8563 nk_draw_list_stroke_rect(
struct nk_draw_list *list,
struct nk_rect rect,
8564 struct nk_color col,
float rounding,
float thickness)
8567 if (!list || !col.
a)
return;
8568 nk_draw_list_path_rect_to(list,
nk_vec2(rect.
x + 0.5f, rect.
y + 0.5f),
8569 nk_vec2(rect.
x + rect.
w + 0.5f, rect.
y + rect.
h + 0.5f), rounding);
8570 nk_draw_list_path_stroke(list, col, NK_STROKE_CLOSED, thickness);
8574 nk_draw_list_fill_rect_multi_color(
struct nk_draw_list *list,
struct nk_rect rect,
8582 nk_draw_index index;
8592 nk_draw_list_push_image(list, list->config.null.texture);
8593 index = (nk_draw_index)list->vertex_count;
8594 vtx = nk_draw_list_alloc_vertices(list, 4);
8595 idx = nk_draw_list_alloc_elements(list, 6);
8596 if (!vtx || !idx)
return;
8598 idx[0] = (nk_draw_index)(index+0); idx[1] = (nk_draw_index)(index+1);
8599 idx[2] = (nk_draw_index)(index+2); idx[3] = (nk_draw_index)(index+0);
8600 idx[4] = (nk_draw_index)(index+2); idx[5] = (nk_draw_index)(index+3);
8602 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(rect.
x, rect.
y), list->config.null.uv, col_left);
8603 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(rect.
x + rect.
w, rect.
y), list->config.null.uv, col_top);
8604 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(rect.
x + rect.
w, rect.
y + rect.
h), list->config.null.uv, col_right);
8605 vtx = nk_draw_vertex(vtx, &list->config,
nk_vec2(rect.
x, rect.
y + rect.
h), list->config.null.uv, col_bottom);
8609 nk_draw_list_fill_triangle(
struct nk_draw_list *list,
struct nk_vec2 a,
8613 if (!list || !col.
a)
return;
8614 nk_draw_list_path_line_to(list, a);
8615 nk_draw_list_path_line_to(list, b);
8616 nk_draw_list_path_line_to(list, c);
8617 nk_draw_list_path_fill(list, col);
8621 nk_draw_list_stroke_triangle(
struct nk_draw_list *list,
struct nk_vec2 a,
8625 if (!list || !col.
a)
return;
8626 nk_draw_list_path_line_to(list, a);
8627 nk_draw_list_path_line_to(list, b);
8628 nk_draw_list_path_line_to(list, c);
8629 nk_draw_list_path_stroke(list, col, NK_STROKE_CLOSED, thickness);
8633 nk_draw_list_fill_circle(
struct nk_draw_list *list,
struct nk_vec2 center,
8634 float radius,
struct nk_color col,
unsigned int segs)
8638 if (!list || !col.
a)
return;
8639 a_max =
NK_PI * 2.0f * ((float)segs - 1.0f) / (float)segs;
8640 nk_draw_list_path_arc_to(list, center, radius, 0.0f, a_max, segs);
8641 nk_draw_list_path_fill(list, col);
8645 nk_draw_list_stroke_circle(
struct nk_draw_list *list,
struct nk_vec2 center,
8646 float radius,
struct nk_color col,
unsigned int segs,
float thickness)
8650 if (!list || !col.
a)
return;
8651 a_max =
NK_PI * 2.0f * ((float)segs - 1.0f) / (float)segs;
8652 nk_draw_list_path_arc_to(list, center, radius, 0.0f, a_max, segs);
8653 nk_draw_list_path_stroke(list, col, NK_STROKE_CLOSED, thickness);
8657 nk_draw_list_stroke_curve(
struct nk_draw_list *list,
struct nk_vec2 p0,
8659 struct nk_color col,
unsigned int segments,
float thickness)
8662 if (!list || !col.
a)
return;
8663 nk_draw_list_path_line_to(list, p0);
8664 nk_draw_list_path_curve_to(list, cp0, cp1, p1, segments);
8665 nk_draw_list_path_stroke(list, col, NK_STROKE_OPEN, thickness);
8669 nk_draw_list_push_rect_uv(
struct nk_draw_list *list,
struct nk_vec2 a,
8681 nk_draw_index index;
8691 index = (nk_draw_index)list->vertex_count;
8692 vtx = nk_draw_list_alloc_vertices(list, 4);
8693 idx = nk_draw_list_alloc_elements(list, 6);
8694 if (!vtx || !idx)
return;
8696 idx[0] = (nk_draw_index)(index+0); idx[1] = (nk_draw_index)(index+1);
8697 idx[2] = (nk_draw_index)(index+2); idx[3] = (nk_draw_index)(index+0);
8698 idx[4] = (nk_draw_index)(index+2); idx[5] = (nk_draw_index)(index+3);
8700 vtx = nk_draw_vertex(vtx, &list->config, a, uva, col);
8701 vtx = nk_draw_vertex(vtx, &list->config, b, uvb, col);
8702 vtx = nk_draw_vertex(vtx, &list->config, c, uvc, col);
8703 vtx = nk_draw_vertex(vtx, &list->config, d, uvd, col);
8707 nk_draw_list_add_image(
struct nk_draw_list *list,
struct nk_image texture,
8713 nk_draw_list_push_image(list, texture.
handle);
8717 uv[0].
x = (float)texture.
region[0]/(
float)texture.
w;
8718 uv[0].
y = (float)texture.
region[1]/(
float)texture.
h;
8719 uv[1].
x = (float)(texture.
region[0] + texture.
region[2])/(float)texture.
w;
8720 uv[1].
y = (
float)(texture.
region[1] + texture.
region[3])/(
float)texture.
h;
8721 nk_draw_list_push_rect_uv(list,
nk_vec2(rect.
x, rect.
y),
8722 nk_vec2(rect.
x + rect.
w, rect.
y + rect.
h), uv[0], uv[1], color);
8723 }
else nk_draw_list_push_rect_uv(list,
nk_vec2(rect.
x, rect.
y),
8729 nk_draw_list_add_text(
struct nk_draw_list *list,
const struct nk_user_font *font,
8730 struct nk_rect rect,
const char *text,
int len,
float font_height,
8735 nk_rune unicode = 0;
8738 int next_glyph_len = 0;
8739 struct nk_user_font_glyph g;
8742 if (!list || !len || !text)
return;
8744 list->clip_rect.x, list->clip_rect.y, list->clip_rect.w, list->clip_rect.h))
return;
8746 nk_draw_list_push_image(list, font->texture);
8749 if (!glyph_len)
return;
8752 fg.
a = (
nk_byte)((
float)fg.
a * list->config.global_alpha);
8753 while (text_len < len && glyph_len) {
8754 float gx, gy, gh, gw;
8755 float char_width = 0;
8759 next_glyph_len =
nk_utf_decode(text + text_len + glyph_len, &next, (
int)len - text_len);
8760 font->query(font->
userdata, font_height, &g, unicode,
8764 gx = x + g.offset.x;
8765 gy = rect.
y + g.offset.y;
8766 gw = g.width; gh = g.height;
8767 char_width = g.xadvance;
8768 nk_draw_list_push_rect_uv(list,
nk_vec2(gx,gy),
nk_vec2(gx + gw, gy+ gh),
8769 g.uv[0], g.uv[1], fg);
8772 text_len += glyph_len;
8774 glyph_len = next_glyph_len;
8788 NK_ASSERT(vertices);
8789 NK_ASSERT(elements);
8793 if (!ctx || !cmds || !vertices || !elements || !config || !config->
vertex_layout)
8796 nk_draw_list_setup(&ctx->draw_list, config, cmds, vertices, elements);
8799 #ifdef NK_INCLUDE_COMMAND_USERDATA
8800 ctx->draw_list.userdata = cmd->userdata;
8802 switch (cmd->
type) {
8806 nk_draw_list_add_clip(&ctx->draw_list,
nk_rect(s->
x, s->
y, s->
w, s->
h));
8822 nk_draw_list_stroke_rect(&ctx->draw_list,
nk_rect(r->
x, r->
y, r->
w, r->
h),
8827 nk_draw_list_fill_rect(&ctx->draw_list,
nk_rect(r->
x, r->
y, r->
w, r->
h),
8832 nk_draw_list_fill_rect_multi_color(&ctx->draw_list,
nk_rect(r->
x, r->
y, r->
w, r->
h),
8837 nk_draw_list_stroke_circle(&ctx->draw_list,
nk_vec2((
float)c->
x + (
float)c->
w/2,
8838 (
float)c->
y + (
float)c->
h/2), (
float)c->
w/2, c->
color,
8843 nk_draw_list_fill_circle(&ctx->draw_list,
nk_vec2((
float)c->
x + (
float)c->
w/2,
8844 (
float)c->
y + (
float)c->
h/2), (
float)c->
w/2, c->
color,
8849 nk_draw_list_path_line_to(&ctx->draw_list,
nk_vec2(c->
cx, c->
cy));
8850 nk_draw_list_path_arc_to(&ctx->draw_list,
nk_vec2(c->
cx, c->
cy), c->
r,
8856 nk_draw_list_path_line_to(&ctx->draw_list,
nk_vec2(c->
cx, c->
cy));
8857 nk_draw_list_path_arc_to(&ctx->draw_list,
nk_vec2(c->
cx, c->
cy), c->
r,
8859 nk_draw_list_path_fill(&ctx->draw_list, c->
color);
8863 nk_draw_list_stroke_triangle(&ctx->draw_list,
nk_vec2(t->
a.
x, t->
a.
y),
8869 nk_draw_list_fill_triangle(&ctx->draw_list,
nk_vec2(t->
a.
x, t->
a.
y),
8877 nk_draw_list_path_line_to(&ctx->draw_list, pnt);
8886 nk_draw_list_path_line_to(&ctx->draw_list, pnt);
8888 nk_draw_list_path_fill(&ctx->draw_list, p->
color);
8895 nk_draw_list_path_line_to(&ctx->draw_list, pnt);
8901 nk_draw_list_add_text(&ctx->draw_list, t->
font,
nk_rect(t->
x, t->
y, t->
w, t->
h),
8906 nk_draw_list_add_image(&ctx->draw_list, i->
img,
nk_rect(i->
x, i->
y, i->
w, i->
h), i->
col);
8920 NK_API const struct nk_draw_command*
8923 {
return nk__draw_list_begin(&ctx->draw_list, buffer);}
8925 NK_API const struct nk_draw_command*
8927 {
return nk__draw_list_end(&ctx->draw_list, buffer);}
8929 NK_API const struct nk_draw_command*
8930 nk__draw_next(
const struct nk_draw_command *cmd,
8932 {
return nk__draw_list_next(cmd, buffer, &ctx->draw_list);}
8943 #ifdef NK_INCLUDE_FONT_BAKING
8951 #define NK_RP__MAXVAL 0xffff
8952 typedef unsigned short nk_rp_coord;
8967 struct nk_rp_node *next;
8970 struct nk_rp_context {
8977 struct nk_rp_node *active_head;
8978 struct nk_rp_node *free_head;
8979 struct nk_rp_node extra[2];
8983 struct nk_rp__findresult {
8985 struct nk_rp_node **prev_link;
8988 enum NK_RP_HEURISTIC {
8989 NK_RP_HEURISTIC_Skyline_default=0,
8990 NK_RP_HEURISTIC_Skyline_BL_sortHeight = NK_RP_HEURISTIC_Skyline_default,
8991 NK_RP_HEURISTIC_Skyline_BF_sortHeight
8993 enum NK_RP_INIT_STATE{NK_RP__INIT_skyline = 1};
8996 nk_rp_setup_allow_out_of_mem(
struct nk_rp_context *context,
int allow_out_of_mem)
8998 if (allow_out_of_mem)
9011 context->align = (context->width + context->num_nodes-1) / context->num_nodes;
9016 nk_rp_init_target(
struct nk_rp_context *context,
int width,
int height,
9017 struct nk_rp_node *nodes,
int num_nodes)
9020 #ifndef STBRP_LARGE_RECTS
9021 NK_ASSERT(width <= 0xffff && height <= 0xffff);
9024 for (i=0; i < num_nodes-1; ++i)
9025 nodes[i].next = &nodes[i+1];
9027 context->init_mode = NK_RP__INIT_skyline;
9028 context->heuristic = NK_RP_HEURISTIC_Skyline_default;
9029 context->free_head = &nodes[0];
9030 context->active_head = &context->extra[0];
9031 context->width = width;
9032 context->height = height;
9033 context->num_nodes = num_nodes;
9034 nk_rp_setup_allow_out_of_mem(context, 0);
9037 context->extra[0].x = 0;
9038 context->extra[0].y = 0;
9039 context->extra[0].next = &context->extra[1];
9040 context->extra[1].x = (nk_rp_coord) width;
9041 context->extra[1].y = 65535;
9042 context->extra[1].next = 0;
9047 nk_rp__skyline_find_min_y(
struct nk_rp_context *c,
struct nk_rp_node *first,
9048 int x0,
int width,
int *pwaste)
9050 struct nk_rp_node *node = first;
9051 int x1 = x0 + width;
9052 int min_y, visited_width, waste_area;
9053 NK_ASSERT(first->x <= x0);
9056 NK_ASSERT(node->next->x > x0);
9058 NK_ASSERT(node->x <= x0);
9063 while (node->x < x1)
9065 if (node->y > min_y) {
9069 waste_area += visited_width * (node->y - min_y);
9073 visited_width += node->next->x - x0;
9075 visited_width += node->next->x - node->x;
9078 int under_width = node->next->x - node->x;
9079 if (under_width + visited_width > width)
9080 under_width = width - visited_width;
9081 waste_area += under_width * (min_y - node->y);
9082 visited_width += under_width;
9086 *pwaste = waste_area;
9091 nk_rp__skyline_find_best_pos(struct nk_rp_context *c,
int width,
int height)
9093 int best_waste = (1<<30), best_x, best_y = (1 << 30);
9094 struct nk_rp__findresult fr;
9095 struct nk_rp_node **prev, *node, *tail, **best = 0;
9098 width = (width + c->align - 1);
9099 width -= width % c->align;
9100 NK_ASSERT(width % c->align == 0);
9102 node = c->active_head;
9103 prev = &c->active_head;
9104 while (node->x + width <= c->width) {
9106 y = nk_rp__skyline_find_min_y(c, node, node->x, width, &waste);
9108 if (c->heuristic == NK_RP_HEURISTIC_Skyline_BL_sortHeight) {
9116 if (y + height <= c->height) {
9118 if (y < best_y || (y == best_y && waste < best_waste)) {
9128 best_x = (best == 0) ? 0 : (*best)->x;
9146 if (c->heuristic == NK_RP_HEURISTIC_Skyline_BF_sortHeight)
9148 tail = c->active_head;
9149 node = c->active_head;
9150 prev = &c->active_head;
9152 while (tail->x < width)
9156 int xpos = tail->x - width;
9158 NK_ASSERT(xpos >= 0);
9160 while (node->next->x <= xpos) {
9164 NK_ASSERT(node->next->x > xpos && node->x <= xpos);
9165 y = nk_rp__skyline_find_min_y(c, node, xpos, width, &waste);
9166 if (y + height < c->height) {
9168 if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) {
9170 NK_ASSERT(y <= best_y);
9180 fr.prev_link = best;
9187 nk_rp__skyline_pack_rectangle(struct nk_rp_context *context,
int width,
int height)
9190 struct nk_rp__findresult res = nk_rp__skyline_find_best_pos(context, width, height);
9191 struct nk_rp_node *node, *cur;
9197 if (res.prev_link == 0 || res.y + height > context->height || context->free_head == 0) {
9203 node = context->free_head;
9204 node->x = (nk_rp_coord) res.x;
9205 node->y = (nk_rp_coord) (res.y + height);
9207 context->free_head = node->next;
9212 cur = *res.prev_link;
9213 if (cur->x < res.x) {
9215 struct nk_rp_node *next = cur->next;
9219 *res.prev_link = node;
9224 while (cur->next && cur->next->x <= res.x + width) {
9225 struct nk_rp_node *next = cur->next;
9227 cur->next = context->free_head;
9228 context->free_head = cur;
9234 if (cur->x < res.x + width)
9235 cur->x = (nk_rp_coord) (res.x + width);
9240 nk_rect_height_compare(
const void *a,
const void *b)
9242 const struct nk_rp_rect *p = (
const struct nk_rp_rect *) a;
9243 const struct nk_rp_rect *q = (
const struct nk_rp_rect *) b;
9248 return (p->w > q->w) ? -1 : (p->w < q->w);
9252 nk_rect_original_order(
const void *a,
const void *b)
9254 const struct nk_rp_rect *p = (
const struct nk_rp_rect *) a;
9255 const struct nk_rp_rect *q = (
const struct nk_rp_rect *) b;
9256 return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed);
9260 nk_rp_qsort(
struct nk_rp_rect *array,
unsigned int len,
int(*cmp)(
const void*,
const void*))
9263 #define NK_MAX_SORT_STACK 64
9264 unsigned right, left = 0, stack[NK_MAX_SORT_STACK], pos = 0;
9265 unsigned seed = len/2 * 69069+1;
9267 for (; left+1 < len; len++) {
9268 struct nk_rp_rect pivot, tmp;
9269 if (pos == NK_MAX_SORT_STACK) len = stack[pos = 0];
9270 pivot = array[left+seed%(len-left)];
9271 seed = seed * 69069 + 1;
9273 for (right = left-1;;) {
9274 while (cmp(&array[++right], &pivot) < 0);
9275 while (cmp(&pivot, &array[--len]) < 0);
9276 if (right >= len)
break;
9278 array[right] = array[len];
9282 if (pos == 0)
break;
9286 #undef NK_MAX_SORT_STACK
9290 nk_rp_pack_rects(
struct nk_rp_context *context,
struct nk_rp_rect *rects,
int num_rects)
9294 for (i=0; i < num_rects; ++i) {
9295 rects[i].was_packed = i;
9299 nk_rp_qsort(rects, (
unsigned)num_rects, nk_rect_height_compare);
9301 for (i=0; i < num_rects; ++i) {
9302 struct nk_rp__findresult fr = nk_rp__skyline_pack_rectangle(context, rects[i].w, rects[i].h);
9304 rects[i].x = (nk_rp_coord) fr.x;
9305 rects[i].y = (nk_rp_coord) fr.y;
9307 rects[i].x = rects[i].y = NK_RP__MAXVAL;
9312 nk_rp_qsort(rects, (
unsigned)num_rects, nk_rect_original_order);
9315 for (i=0; i < num_rects; ++i)
9316 rects[i].was_packed = !(rects[i].x == NK_RP__MAXVAL && rects[i].y == NK_RP__MAXVAL);
9327 #define NK_TT_MAX_OVERSAMPLE 8
9328 #define NK_TT__OVER_MASK (NK_TT_MAX_OVERSAMPLE-1)
9330 struct nk_tt_bakedchar {
9331 unsigned short x0,y0,x1,y1;
9333 float xoff,yoff,xadvance;
9336 struct nk_tt_aligned_quad{
9341 struct nk_tt_packedchar {
9342 unsigned short x0,y0,x1,y1;
9344 float xoff,yoff,xadvance;
9348 struct nk_tt_pack_range {
9350 int first_unicode_codepoint_in_range;
9352 int *array_of_unicode_codepoints;
9355 struct nk_tt_packedchar *chardata_for_range;
9356 unsigned char h_oversample, v_oversample;
9360 struct nk_tt_pack_context {
9364 int stride_in_bytes;
9366 unsigned int h_oversample, v_oversample;
9367 unsigned char *pixels;
9371 struct nk_tt_fontinfo {
9372 const unsigned char* data;
9375 int loca,head,glyf,hhea,hmtx,kern;
9377 int indexToLocFormat;
9386 struct nk_tt_vertex {
9388 unsigned char type,padding;
9391 struct nk_tt__bitmap{
9393 unsigned char *pixels;
9396 struct nk_tt__hheap_chunk {
9397 struct nk_tt__hheap_chunk *next;
9399 struct nk_tt__hheap {
9401 struct nk_tt__hheap_chunk *head;
9403 int num_remaining_in_head_chunk;
9406 struct nk_tt__edge {
9411 struct nk_tt__active_edge {
9412 struct nk_tt__active_edge *next;
9418 struct nk_tt__point {
float x,y;};
9420 #define NK_TT_MACSTYLE_DONTCARE 0
9421 #define NK_TT_MACSTYLE_BOLD 1
9422 #define NK_TT_MACSTYLE_ITALIC 2
9423 #define NK_TT_MACSTYLE_UNDERSCORE 4
9424 #define NK_TT_MACSTYLE_NONE 8
9428 NK_TT_PLATFORM_ID_UNICODE =0,
9429 NK_TT_PLATFORM_ID_MAC =1,
9430 NK_TT_PLATFORM_ID_ISO =2,
9431 NK_TT_PLATFORM_ID_MICROSOFT =3
9435 NK_TT_UNICODE_EID_UNICODE_1_0 =0,
9436 NK_TT_UNICODE_EID_UNICODE_1_1 =1,
9437 NK_TT_UNICODE_EID_ISO_10646 =2,
9438 NK_TT_UNICODE_EID_UNICODE_2_0_BMP=3,
9439 NK_TT_UNICODE_EID_UNICODE_2_0_FULL=4
9443 NK_TT_MS_EID_SYMBOL =0,
9444 NK_TT_MS_EID_UNICODE_BMP =1,
9445 NK_TT_MS_EID_SHIFTJIS =2,
9446 NK_TT_MS_EID_UNICODE_FULL =10
9450 NK_TT_MAC_EID_ROMAN =0, NK_TT_MAC_EID_ARABIC =4,
9451 NK_TT_MAC_EID_JAPANESE =1, NK_TT_MAC_EID_HEBREW =5,
9452 NK_TT_MAC_EID_CHINESE_TRAD =2, NK_TT_MAC_EID_GREEK =6,
9453 NK_TT_MAC_EID_KOREAN =3, NK_TT_MAC_EID_RUSSIAN =7
9458 NK_TT_MS_LANG_ENGLISH =0x0409, NK_TT_MS_LANG_ITALIAN =0x0410,
9459 NK_TT_MS_LANG_CHINESE =0x0804, NK_TT_MS_LANG_JAPANESE =0x0411,
9460 NK_TT_MS_LANG_DUTCH =0x0413, NK_TT_MS_LANG_KOREAN =0x0412,
9461 NK_TT_MS_LANG_FRENCH =0x040c, NK_TT_MS_LANG_RUSSIAN =0x0419,
9462 NK_TT_MS_LANG_GERMAN =0x0407, NK_TT_MS_LANG_SPANISH =0x0409,
9463 NK_TT_MS_LANG_HEBREW =0x040d, NK_TT_MS_LANG_SWEDISH =0x041D
9467 NK_TT_MAC_LANG_ENGLISH =0 , NK_TT_MAC_LANG_JAPANESE =11,
9468 NK_TT_MAC_LANG_ARABIC =12, NK_TT_MAC_LANG_KOREAN =23,
9469 NK_TT_MAC_LANG_DUTCH =4 , NK_TT_MAC_LANG_RUSSIAN =32,
9470 NK_TT_MAC_LANG_FRENCH =1 , NK_TT_MAC_LANG_SPANISH =6 ,
9471 NK_TT_MAC_LANG_GERMAN =2 , NK_TT_MAC_LANG_SWEDISH =5 ,
9472 NK_TT_MAC_LANG_HEBREW =10, NK_TT_MAC_LANG_CHINESE_SIMPLIFIED =33,
9473 NK_TT_MAC_LANG_ITALIAN =3 , NK_TT_MAC_LANG_CHINESE_TRAD =19
9476 #define nk_ttBYTE(p) (* (const nk_byte *) (p))
9477 #define nk_ttCHAR(p) (* (const char *) (p))
9479 #if defined(NK_BIGENDIAN) && !defined(NK_ALLOW_UNALIGNED_TRUETYPE)
9480 #define nk_ttUSHORT(p) (* (nk_ushort *) (p))
9481 #define nk_ttSHORT(p) (* (nk_short *) (p))
9482 #define nk_ttULONG(p) (* (nk_uint *) (p))
9483 #define nk_ttLONG(p) (* (nk_int *) (p))
9485 static nk_ushort nk_ttUSHORT(
const nk_byte *p) {
return (nk_ushort)(p[0]*256 + p[1]); }
9486 static nk_short nk_ttSHORT(
const nk_byte *p) {
return (nk_short)(p[0]*256 + p[1]); }
9487 static nk_uint nk_ttULONG(
const nk_byte *p) {
return (nk_uint)((p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]); }
9490 #define nk_tt_tag4(p,c0,c1,c2,c3)\
9491 ((p)[0] == (c0) && (p)[1] == (c1) && (p)[2] == (c2) && (p)[3] == (c3))
9492 #define nk_tt_tag(p,str) nk_tt_tag4(p,str[0],str[1],str[2],str[3])
9495 int glyph_index,
struct nk_tt_vertex **pvertices);
9498 nk_tt__find_table(
const nk_byte *data, nk_uint fontstart,
const char *tag)
9501 nk_int num_tables = nk_ttUSHORT(data+fontstart+4);
9502 nk_uint tabledir = fontstart + 12;
9504 for (i = 0; i < num_tables; ++i) {
9505 nk_uint loc = tabledir + (
nk_uint)(16*i);
9506 if (nk_tt_tag(data+loc+0, tag))
9507 return nk_ttULONG(data+loc+8);
9513 nk_tt_InitFont(
struct nk_tt_fontinfo *info,
const unsigned char *data2,
int fontstart)
9517 const nk_byte *data = (
const nk_byte *) data2;
9520 info->fontstart = fontstart;
9522 cmap = nk_tt__find_table(data, (nk_uint)fontstart,
"cmap");
9523 info->loca = (
int)nk_tt__find_table(data, (nk_uint)fontstart,
"loca");
9524 info->head = (
int)nk_tt__find_table(data, (nk_uint)fontstart,
"head");
9525 info->glyf = (
int)nk_tt__find_table(data, (nk_uint)fontstart,
"glyf");
9526 info->hhea = (
int)nk_tt__find_table(data, (nk_uint)fontstart,
"hhea");
9527 info->hmtx = (
int)nk_tt__find_table(data, (nk_uint)fontstart,
"hmtx");
9528 info->kern = (
int)nk_tt__find_table(data, (nk_uint)fontstart,
"kern");
9529 if (!cmap || !info->loca || !info->head || !info->glyf || !info->hhea || !info->hmtx)
9532 t = nk_tt__find_table(data, (nk_uint)fontstart,
"maxp");
9533 if (t) info->numGlyphs = nk_ttUSHORT(data+t+4);
9534 else info->numGlyphs = 0xffff;
9539 numTables = nk_ttUSHORT(data + cmap + 2);
9540 info->index_map = 0;
9541 for (i=0; i < numTables; ++i)
9543 nk_uint encoding_record = cmap + 4 + 8 * (
nk_uint)i;
9545 switch(nk_ttUSHORT(data+encoding_record)) {
9546 case NK_TT_PLATFORM_ID_MICROSOFT:
9547 switch (nk_ttUSHORT(data+encoding_record+2)) {
9548 case NK_TT_MS_EID_UNICODE_BMP:
9549 case NK_TT_MS_EID_UNICODE_FULL:
9551 info->index_map = (
int)(cmap + nk_ttULONG(data+encoding_record+4));
9555 case NK_TT_PLATFORM_ID_UNICODE:
9558 info->index_map = (
int)(cmap + nk_ttULONG(data+encoding_record+4));
9563 if (info->index_map == 0)
9565 info->indexToLocFormat = nk_ttUSHORT(data+info->head + 50);
9570 nk_tt_FindGlyphIndex(
const struct nk_tt_fontinfo *info,
int unicode_codepoint)
9572 const nk_byte *data = info->data;
9573 nk_uint index_map = (
nk_uint)info->index_map;
9575 nk_ushort format = nk_ttUSHORT(data + index_map + 0);
9577 nk_int bytes = nk_ttUSHORT(data + index_map + 2);
9578 if (unicode_codepoint < bytes-6)
9579 return nk_ttBYTE(data + index_map + 6 + unicode_codepoint);
9581 }
else if (format == 6) {
9582 nk_uint first = nk_ttUSHORT(data + index_map + 6);
9583 nk_uint count = nk_ttUSHORT(data + index_map + 8);
9584 if ((nk_uint) unicode_codepoint >= first && (nk_uint) unicode_codepoint < first+count)
9585 return nk_ttUSHORT(data + index_map + 10 + (unicode_codepoint - (
int)first)*2);
9587 }
else if (format == 2) {
9590 }
else if (format == 4) {
9591 nk_ushort segcount = nk_ttUSHORT(data+index_map+6) >> 1;
9592 nk_ushort searchRange = nk_ttUSHORT(data+index_map+8) >> 1;
9593 nk_ushort entrySelector = nk_ttUSHORT(data+index_map+10);
9594 nk_ushort rangeShift = nk_ttUSHORT(data+index_map+12) >> 1;
9597 nk_uint endCount = index_map + 14;
9598 nk_uint search = endCount;
9600 if (unicode_codepoint > 0xffff)
9605 if (unicode_codepoint >= nk_ttUSHORT(data + search + rangeShift*2))
9606 search += (
nk_uint)(rangeShift*2);
9610 while (entrySelector) {
9613 end = nk_ttUSHORT(data + search + searchRange*2);
9614 if (unicode_codepoint > end)
9615 search += (
nk_uint)(searchRange*2);
9621 nk_ushort offset, start;
9622 nk_ushort item = (
nk_ushort) ((search - endCount) >> 1);
9624 NK_ASSERT(unicode_codepoint <= nk_ttUSHORT(data + endCount + 2*item));
9625 start = nk_ttUSHORT(data + index_map + 14 + segcount*2 + 2 + 2*item);
9626 if (unicode_codepoint < start)
9629 offset = nk_ttUSHORT(data + index_map + 14 + segcount*6 + 2 + 2*item);
9631 return (nk_ushort) (unicode_codepoint + nk_ttSHORT(data + index_map + 14 + segcount*4 + 2 + 2*item));
9633 return nk_ttUSHORT(data + offset + (unicode_codepoint-start)*2 + index_map + 14 + segcount*6 + 2 + 2*item);
9635 }
else if (format == 12 || format == 13) {
9636 nk_uint ngroups = nk_ttULONG(data+index_map+12);
9638 low = 0; high = (
nk_int)ngroups;
9640 while (low < high) {
9641 nk_int mid = low + ((high-low) >> 1);
9642 nk_uint start_char = nk_ttULONG(data+index_map+16+mid*12);
9643 nk_uint end_char = nk_ttULONG(data+index_map+16+mid*12+4);
9644 if ((nk_uint) unicode_codepoint < start_char)
9646 else if ((nk_uint) unicode_codepoint > end_char)
9649 nk_uint start_glyph = nk_ttULONG(data+index_map+16+mid*12+8);
9651 return (
int)start_glyph + (
int)unicode_codepoint - (
int)start_char;
9653 return (
int)start_glyph;
9664 nk_tt_setvertex(struct nk_tt_vertex *v, nk_byte type, nk_int x, nk_int y, nk_int cx, nk_int cy)
9674 nk_tt__GetGlyfOffset(
const struct nk_tt_fontinfo *info,
int glyph_index)
9677 if (glyph_index >= info->numGlyphs)
return -1;
9678 if (info->indexToLocFormat >= 2)
return -1;
9680 if (info->indexToLocFormat == 0) {
9681 g1 = info->glyf + nk_ttUSHORT(info->data + info->loca + glyph_index * 2) * 2;
9682 g2 = info->glyf + nk_ttUSHORT(info->data + info->loca + glyph_index * 2 + 2) * 2;
9684 g1 = info->glyf + (
int)nk_ttULONG (info->data + info->loca + glyph_index * 4);
9685 g2 = info->glyf + (
int)nk_ttULONG (info->data + info->loca + glyph_index * 4 + 4);
9687 return g1==g2 ? -1 : g1;
9691 nk_tt_GetGlyphBox(
const struct nk_tt_fontinfo *info,
int glyph_index,
9692 int *x0,
int *y0,
int *x1,
int *y1)
9694 int g = nk_tt__GetGlyfOffset(info, glyph_index);
9695 if (g < 0)
return 0;
9697 if (x0) *x0 = nk_ttSHORT(info->data + g + 2);
9698 if (y0) *y0 = nk_ttSHORT(info->data + g + 4);
9699 if (x1) *x1 = nk_ttSHORT(info->data + g + 6);
9700 if (y1) *y1 = nk_ttSHORT(info->data + g + 8);
9705 stbtt__close_shape(
struct nk_tt_vertex *vertices,
int num_vertices,
int was_off,
9706 int start_off, nk_int sx, nk_int sy, nk_int scx, nk_int scy, nk_int cx, nk_int cy)
9710 nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vcurve, (cx+scx)>>1, (cy+scy)>>1, cx,cy);
9711 nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vcurve, sx,sy,scx,scy);
9714 nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vcurve,sx,sy,cx,cy);
9716 nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vline,sx,sy,0,0);
9718 return num_vertices;
9722 nk_tt_GetGlyphShape(
const struct nk_tt_fontinfo *info,
struct nk_allocator *alloc,
9723 int glyph_index,
struct nk_tt_vertex **pvertices)
9725 nk_short numberOfContours;
9726 const nk_byte *endPtsOfContours;
9727 const nk_byte *data = info->data;
9728 struct nk_tt_vertex *vertices=0;
9730 int g = nk_tt__GetGlyfOffset(info, glyph_index);
9733 if (g < 0)
return 0;
9734 numberOfContours = nk_ttSHORT(data + g);
9735 if (numberOfContours > 0) {
9736 nk_byte flags=0,flagcount;
9737 nk_int ins, i,j=0,
m,n, next_move, was_off=0, off, start_off=0;
9738 nk_int x,y,cx,cy,sx,sy, scx,scy;
9739 const nk_byte *points;
9740 endPtsOfContours = (data + g + 10);
9741 ins = nk_ttUSHORT(data + g + 10 + numberOfContours * 2);
9742 points = data + g + 10 + numberOfContours * 2 + 2 + ins;
9744 n = 1+nk_ttUSHORT(endPtsOfContours + numberOfContours*2-2);
9745 m = n + 2*numberOfContours;
9746 vertices = (
struct nk_tt_vertex *)alloc->
alloc(alloc->
userdata, 0, (nk_size)m *
sizeof(vertices[0]));
9759 for (i=0; i < n; ++i) {
9760 if (flagcount == 0) {
9763 flagcount = *points++;
9765 vertices[off+i].type = flags;
9770 for (i=0; i < n; ++i) {
9771 flags = vertices[off+i].type;
9773 nk_short dx = *points++;
9774 x += (flags & 16) ? dx : -dx;
9776 if (!(flags & 16)) {
9777 x = x + (
nk_short) (points[0]*256 + points[1]);
9786 for (i=0; i < n; ++i) {
9787 flags = vertices[off+i].type;
9789 nk_short dy = *points++;
9790 y += (flags & 32) ? dy : -dy;
9792 if (!(flags & 32)) {
9793 y = y + (
nk_short) (points[0]*256 + points[1]);
9802 sx = sy = cx = cy = scx = scy = 0;
9803 for (i=0; i < n; ++i)
9805 flags = vertices[off+i].type;
9809 if (next_move == i) {
9811 num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy);
9814 start_off = !(flags & 1);
9820 if (!(vertices[off+i+1].type & 1)) {
9822 sx = (x + (
nk_int) vertices[off+i+1].x) >> 1;
9823 sy = (y + (
nk_int) vertices[off+i+1].y) >> 1;
9826 sx = (
nk_int) vertices[off+i+1].x;
9827 sy = (
nk_int) vertices[off+i+1].y;
9834 nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vmove,sx,sy,0,0);
9836 next_move = 1 + nk_ttUSHORT(endPtsOfContours+j*2);
9842 nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vcurve, (cx+x)>>1, (cy+y)>>1, cx, cy);
9848 nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vcurve, x,y, cx, cy);
9849 else nk_tt_setvertex(&vertices[num_vertices++], NK_TT_vline, x,y,0,0);
9854 num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy);
9855 }
else if (numberOfContours == -1) {
9858 const nk_byte *comp = data + g + 10;
9864 nk_ushort flags, gidx;
9865 int comp_num_verts = 0, i;
9866 struct nk_tt_vertex *comp_verts = 0, *tmp = 0;
9867 float mtx[6] = {1,0,0,1,0,0},
m, n;
9869 flags = (
nk_ushort)nk_ttSHORT(comp); comp+=2;
9870 gidx = (
nk_ushort)nk_ttSHORT(comp); comp+=2;
9874 mtx[4] = nk_ttSHORT(comp); comp+=2;
9875 mtx[5] = nk_ttSHORT(comp); comp+=2;
9877 mtx[4] = nk_ttCHAR(comp); comp+=1;
9878 mtx[5] = nk_ttCHAR(comp); comp+=1;
9884 if (flags & (1<<3)) {
9885 mtx[0] = mtx[3] = nk_ttSHORT(comp)/16384.0f; comp+=2;
9886 mtx[1] = mtx[2] = 0;
9887 }
else if (flags & (1<<6)) {
9888 mtx[0] = nk_ttSHORT(comp)/16384.0f; comp+=2;
9889 mtx[1] = mtx[2] = 0;
9890 mtx[3] = nk_ttSHORT(comp)/16384.0f; comp+=2;
9891 }
else if (flags & (1<<7)) {
9892 mtx[0] = nk_ttSHORT(comp)/16384.0f; comp+=2;
9893 mtx[1] = nk_ttSHORT(comp)/16384.0f; comp+=2;
9894 mtx[2] = nk_ttSHORT(comp)/16384.0f; comp+=2;
9895 mtx[3] = nk_ttSHORT(comp)/16384.0f; comp+=2;
9899 m = (float) NK_SQRT(mtx[0]*mtx[0] + mtx[1]*mtx[1]);
9900 n = (float) NK_SQRT(mtx[2]*mtx[2] + mtx[3]*mtx[3]);
9903 comp_num_verts = nk_tt_GetGlyphShape(info, alloc, gidx, &comp_verts);
9904 if (comp_num_verts > 0)
9907 for (i = 0; i < comp_num_verts; ++i) {
9908 struct nk_tt_vertex* v = &comp_verts[i];
9911 v->x = (short)(m * (mtx[0]*x + mtx[2]*y + mtx[4]));
9912 v->y = (short)(n * (mtx[1]*x + mtx[3]*y + mtx[5]));
9914 v->cx = (short)(m * (mtx[0]*x + mtx[2]*y + mtx[4]));
9915 v->cy = (short)(n * (mtx[1]*x + mtx[3]*y + mtx[5]));
9918 tmp = (
struct nk_tt_vertex*)alloc->
alloc(alloc->
userdata, 0,
9919 (nk_size)(num_vertices+comp_num_verts)*
sizeof(
struct nk_tt_vertex));
9922 if (comp_verts) alloc->
free(alloc->
userdata, comp_verts);
9925 if (num_vertices > 0) NK_MEMCPY(tmp, vertices, (nk_size)num_vertices*
sizeof(
struct nk_tt_vertex));
9926 NK_MEMCPY(tmp+num_vertices, comp_verts, (nk_size)comp_num_verts*
sizeof(
struct nk_tt_vertex));
9930 num_vertices += comp_num_verts;
9933 more = flags & (1<<5);
9935 }
else if (numberOfContours < 0) {
9941 *pvertices = vertices;
9942 return num_vertices;
9946 nk_tt_GetGlyphHMetrics(
const struct nk_tt_fontinfo *info,
int glyph_index,
9947 int *advanceWidth,
int *leftSideBearing)
9949 nk_ushort numOfLongHorMetrics = nk_ttUSHORT(info->data+info->hhea + 34);
9950 if (glyph_index < numOfLongHorMetrics) {
9952 *advanceWidth = nk_ttSHORT(info->data + info->hmtx + 4*glyph_index);
9953 if (leftSideBearing)
9954 *leftSideBearing = nk_ttSHORT(info->data + info->hmtx + 4*glyph_index + 2);
9957 *advanceWidth = nk_ttSHORT(info->data + info->hmtx + 4*(numOfLongHorMetrics-1));
9958 if (leftSideBearing)
9959 *leftSideBearing = nk_ttSHORT(info->data + info->hmtx + 4*numOfLongHorMetrics + 2*(glyph_index - numOfLongHorMetrics));
9964 nk_tt_GetFontVMetrics(
const struct nk_tt_fontinfo *info,
9965 int *ascent,
int *descent,
int *lineGap)
9967 if (ascent ) *ascent = nk_ttSHORT(info->data+info->hhea + 4);
9968 if (descent) *descent = nk_ttSHORT(info->data+info->hhea + 6);
9969 if (lineGap) *lineGap = nk_ttSHORT(info->data+info->hhea + 8);
9973 nk_tt_ScaleForPixelHeight(
const struct nk_tt_fontinfo *info,
float height)
9975 int fheight = nk_ttSHORT(info->data + info->hhea + 4) - nk_ttSHORT(info->data + info->hhea + 6);
9976 return (
float) height / (float)fheight;
9980 nk_tt_ScaleForMappingEmToPixels(
const struct nk_tt_fontinfo *info,
float pixels)
9982 int unitsPerEm = nk_ttUSHORT(info->data + info->head + 18);
9983 return pixels / (float)unitsPerEm;
9990 nk_tt_GetGlyphBitmapBoxSubpixel(
const struct nk_tt_fontinfo *font,
9991 int glyph,
float scale_x,
float scale_y,
float shift_x,
float shift_y,
9992 int *ix0,
int *iy0,
int *ix1,
int *iy1)
9995 if (!nk_tt_GetGlyphBox(font, glyph, &x0,&y0,&x1,&y1)) {
10003 if (ix0) *ix0 = nk_ifloorf((
float)x0 * scale_x + shift_x);
10004 if (iy0) *iy0 = nk_ifloorf((
float)-y1 * scale_y + shift_y);
10005 if (ix1) *ix1 = nk_iceilf ((
float)x1 * scale_x + shift_x);
10006 if (iy1) *iy1 = nk_iceilf ((
float)-y0 * scale_y + shift_y);
10011 nk_tt_GetGlyphBitmapBox(
const struct nk_tt_fontinfo *font,
int glyph,
10012 float scale_x,
float scale_y,
int *ix0,
int *iy0,
int *ix1,
int *iy1)
10014 nk_tt_GetGlyphBitmapBoxSubpixel(font, glyph, scale_x, scale_y,0.0f,0.0f, ix0, iy0, ix1, iy1);
10021 nk_tt__hheap_alloc(
struct nk_tt__hheap *hh, nk_size size)
10023 if (hh->first_free) {
10024 void *p = hh->first_free;
10025 hh->first_free = * (
void **) p;
10028 if (hh->num_remaining_in_head_chunk == 0) {
10029 int count = (size < 32 ? 2000 : size < 128 ? 800 : 100);
10030 struct nk_tt__hheap_chunk *c = (
struct nk_tt__hheap_chunk *)
10031 hh->alloc.alloc(hh->alloc.userdata, 0,
10032 sizeof(
struct nk_tt__hheap_chunk) + size * (nk_size)count);
10033 if (c == 0)
return 0;
10034 c->next = hh->head;
10036 hh->num_remaining_in_head_chunk = count;
10038 --hh->num_remaining_in_head_chunk;
10039 return (
char *) (hh->head) + size * (nk_size)hh->num_remaining_in_head_chunk;
10044 nk_tt__hheap_free(
struct nk_tt__hheap *hh,
void *p)
10046 *(
void **) p = hh->first_free;
10047 hh->first_free = p;
10051 nk_tt__hheap_cleanup(
struct nk_tt__hheap *hh)
10053 struct nk_tt__hheap_chunk *c = hh->head;
10055 struct nk_tt__hheap_chunk *n = c->next;
10056 hh->alloc.free(hh->alloc.userdata, c);
10062 nk_tt__new_active(
struct nk_tt__hheap *hh,
struct nk_tt__edge *e,
10063 int off_x,
float start_point)
10065 struct nk_tt__active_edge *z = (
struct nk_tt__active_edge *)
10066 nk_tt__hheap_alloc(hh,
sizeof(*z));
10067 float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0);
10071 z->fdy = (dxdy != 0) ? (1/dxdy): 0;
10072 z->fx = e->x0 + dxdy * (start_point - e->y0);
10073 z->fx -= (float)off_x;
10074 z->direction = e->invert ? 1.0f : -1.0f;
10082 nk_tt__handle_clipped_edge(
float *scanline,
int x,
struct nk_tt__active_edge *e,
10083 float x0,
float y0,
float x1,
float y1)
10085 if (y0 == y1)
return;
10086 NK_ASSERT(y0 < y1);
10087 NK_ASSERT(e->sy <= e->ey);
10088 if (y0 > e->ey)
return;
10089 if (y1 < e->sy)
return;
10091 x0 += (x1-x0) * (e->sy - y0) / (y1-y0);
10095 x1 += (x1-x0) * (e->ey - y1) / (y1-y0);
10099 if (x0 == x) NK_ASSERT(x1 <= x+1);
10100 else if (x0 == x+1) NK_ASSERT(x1 >= x);
10101 else if (x0 <= x) NK_ASSERT(x1 <= x);
10102 else if (x0 >= x+1) NK_ASSERT(x1 >= x+1);
10103 else NK_ASSERT(x1 >= x && x1 <= x+1);
10105 if (x0 <= x && x1 <= x)
10106 scanline[x] += e->direction * (y1-y0);
10107 else if (x0 >= x+1 && x1 >= x+1);
10109 NK_ASSERT(x0 >= x && x0 <= x+1 && x1 >= x && x1 <= x+1);
10111 scanline[x] += (float)e->direction * (
float)(y1-y0) * (1.0f-((x0-(
float)x)+(x1-(float)x))/2.0f);
10116 nk_tt__fill_active_edges_new(
float *scanline,
float *scanline_fill,
int len,
10117 struct nk_tt__active_edge *e,
float y_top)
10119 float y_bottom = y_top+1;
10124 NK_ASSERT(e->ey >= y_top);
10129 nk_tt__handle_clipped_edge(scanline,(
int) x0,e, x0,y_top, x0,y_bottom);
10130 nk_tt__handle_clipped_edge(scanline_fill-1,(
int) x0+1,e, x0,y_top, x0,y_bottom);
10132 nk_tt__handle_clipped_edge(scanline_fill-1,0,e, x0,y_top, x0,y_bottom);
10138 float xb = x0 + dx;
10139 float x_top, x_bottom;
10142 NK_ASSERT(e->sy <= y_bottom && e->ey >= y_top);
10147 if (e->sy > y_top) {
10148 x_top = x0 + dx * (e->sy - y_top);
10155 if (e->ey < y_bottom) {
10156 x_bottom = x0 + dx * (e->ey - y_top);
10163 if (x_top >= 0 && x_bottom >= 0 && x_top < len && x_bottom < len)
10166 if ((
int) x_top == (
int) x_bottom) {
10169 int x = (
int) x_top;
10171 NK_ASSERT(x >= 0 && x < len);
10172 scanline[x] += e->direction * (1.0f-(((float)x_top - (
float)x) + ((
float)x_bottom-(float)x))/2.0f) * (float)height;
10173 scanline_fill[x] += e->direction * (float)height;
10176 float y_crossing, step, sign, area;
10178 if (x_top > x_bottom)
10182 y0 = y_bottom - (y0 - y_top);
10183 y1 = y_bottom - (y1 - y_top);
10184 t = y0; y0 = y1; y1 = t;
10185 t = x_bottom; x_bottom = x_top; x_top = t;
10188 t = x0; x0 = xb; xb = t;
10192 x2 = (
int) x_bottom;
10194 y_crossing = ((float)x1+1 - (
float)x0) * (
float)dy + (float)y_top;
10196 sign = e->direction;
10198 area = sign * (y_crossing-y0);
10200 scanline[x1] += area * (1.0f-((float)((
float)x_top - (float)x1)+(float)(x1+1-x1))/2.0f);
10203 for (x = x1+1; x < x2; ++x) {
10204 scanline[x] += area + step/2;
10207 y_crossing += (float)dy * (
float)(x2 - (x1+1));
10209 scanline[x2] += area + sign * (1.0f-((float)(x2-x2)+((float)x_bottom-(
float)x2))/2.0f) * (y1-y_crossing);
10210 scanline_fill[x2] += sign * (y1-y0);
10220 for (x=0; x < len; ++x)
10237 float x1 = (float) (x);
10238 float x2 = (float) (x+1);
10240 float y3 = y_bottom;
10243 yb = ((float)x - x0) / dx + y_top;
10244 y2 = ((float)x+1 - x0) / dx + y_top;
10246 if (x0 < x1 && x3 > x2) {
10247 nk_tt__handle_clipped_edge(scanline,x,e, x0,ya, x1,yb);
10248 nk_tt__handle_clipped_edge(scanline,x,e, x1,yb, x2,y2);
10249 nk_tt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3);
10250 }
else if (x3 < x1 && x0 > x2) {
10251 nk_tt__handle_clipped_edge(scanline,x,e, x0,ya, x2,y2);
10252 nk_tt__handle_clipped_edge(scanline,x,e, x2,y2, x1,yb);
10253 nk_tt__handle_clipped_edge(scanline,x,e, x1,yb, x3,y3);
10254 }
else if (x0 < x1 && x3 > x1) {
10255 nk_tt__handle_clipped_edge(scanline,x,e, x0,ya, x1,yb);
10256 nk_tt__handle_clipped_edge(scanline,x,e, x1,yb, x3,y3);
10257 }
else if (x3 < x1 && x0 > x1) {
10258 nk_tt__handle_clipped_edge(scanline,x,e, x0,ya, x1,yb);
10259 nk_tt__handle_clipped_edge(scanline,x,e, x1,yb, x3,y3);
10260 }
else if (x0 < x2 && x3 > x2) {
10261 nk_tt__handle_clipped_edge(scanline,x,e, x0,ya, x2,y2);
10262 nk_tt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3);
10263 }
else if (x3 < x2 && x0 > x2) {
10264 nk_tt__handle_clipped_edge(scanline,x,e, x0,ya, x2,y2);
10265 nk_tt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3);
10267 nk_tt__handle_clipped_edge(scanline,x,e, x0,ya, x3,y3);
10278 nk_tt__rasterize_sorted_edges(
struct nk_tt__bitmap *result,
struct nk_tt__edge *e,
10279 int n,
int vsubsample,
int off_x,
int off_y,
struct nk_allocator *alloc)
10281 struct nk_tt__hheap hh;
10282 struct nk_tt__active_edge *active = 0;
10284 float scanline_data[129], *scanline, *scanline2;
10290 if (result->w > 64)
10291 scanline = (
float *) alloc->
alloc(alloc->
userdata,0, (nk_size)(result->w*2+1) *
sizeof(
float));
10292 else scanline = scanline_data;
10294 scanline2 = scanline + result->w;
10296 e[n].y0 = (float) (off_y + result->h) + 1;
10298 while (j < result->h)
10301 float scan_y_top = (float)y + 0.0f;
10302 float scan_y_bottom = (float)y + 1.0f;
10303 struct nk_tt__active_edge **step = &active;
10305 NK_MEMSET(scanline , 0, (nk_size)result->w*
sizeof(scanline[0]));
10306 NK_MEMSET(scanline2, 0, (nk_size)(result->w+1)*
sizeof(scanline[0]));
10311 struct nk_tt__active_edge * z = *step;
10312 if (z->ey <= scan_y_top) {
10314 NK_ASSERT(z->direction);
10316 nk_tt__hheap_free(&hh, z);
10318 step = &((*step)->next);
10323 while (e->y0 <= scan_y_bottom) {
10324 if (e->y0 != e->y1) {
10325 struct nk_tt__active_edge *z = nk_tt__new_active(&hh, e, off_x, scan_y_top);
10327 NK_ASSERT(z->ey >= scan_y_top);
10338 nk_tt__fill_active_edges_new(scanline, scanline2+1, result->w, active, scan_y_top);
10342 for (i=0; i < result->w; ++i) {
10345 sum += scanline2[i];
10346 k = scanline[i] + sum;
10347 k = (float)
NK_ABS(k) * 255.0f + 0.5f;
10349 if (m > 255) m = 255;
10350 result->pixels[j*result->stride + i] = (
unsigned char) m;
10356 struct nk_tt__active_edge *z = *step;
10358 step = &((*step)->next);
10363 nk_tt__hheap_cleanup(&hh);
10364 if (scanline != scanline_data)
10368 #define NK_TT__COMPARE(a,b) ((a)->y0 < (b)->y0)
10370 nk_tt__sort_edges_ins_sort(
struct nk_tt__edge *p,
int n)
10373 for (i=1; i < n; ++i) {
10374 struct nk_tt__edge t = p[i], *a = &t;
10377 struct nk_tt__edge *b = &p[j-1];
10378 int c = NK_TT__COMPARE(a,b);
10389 nk_tt__sort_edges_quicksort(
struct nk_tt__edge *p,
int n)
10393 struct nk_tt__edge t;
10394 int c01,c12,c,
m,i,j;
10398 c01 = NK_TT__COMPARE(&p[0],&p[m]);
10399 c12 = NK_TT__COMPARE(&p[m],&p[n-1]);
10405 c = NK_TT__COMPARE(&p[0],&p[n-1]);
10408 z = (c == c12) ? 0 : n-1;
10427 if (!NK_TT__COMPARE(&p[i], &p[0]))
break;
10430 if (!NK_TT__COMPARE(&p[0], &p[j]))
break;
10446 nk_tt__sort_edges_quicksort(p,j);
10450 nk_tt__sort_edges_quicksort(p+i, n-i);
10457 nk_tt__sort_edges(
struct nk_tt__edge *p,
int n)
10459 nk_tt__sort_edges_quicksort(p, n);
10460 nk_tt__sort_edges_ins_sort(p, n);
10464 nk_tt__rasterize(
struct nk_tt__bitmap *result,
struct nk_tt__point *pts,
10465 int *wcount,
int windings,
float scale_x,
float scale_y,
10466 float shift_x,
float shift_y,
int off_x,
int off_y,
int invert,
10469 float y_scale_inv = invert ? -scale_y : scale_y;
10470 struct nk_tt__edge *e;
10472 int vsubsample = 1;
10477 for (i=0; i < windings; ++i)
10480 e = (
struct nk_tt__edge*)
10481 alloc->
alloc(alloc->
userdata, 0,(
sizeof(*e) * (nk_size)(n+1)));
10482 if (e == 0)
return;
10486 for (i=0; i < windings; ++i)
10488 struct nk_tt__point *p = pts +
m;
10491 for (k=0; k < wcount[i]; j=k++) {
10494 if (p[j].y == p[k].y)
10499 if (invert ? p[j].y > p[k].y : p[j].y < p[k].y) {
10503 e[n].x0 = p[a].x * scale_x + shift_x;
10504 e[n].y0 = (p[a].y * y_scale_inv + shift_y) * (
float)vsubsample;
10505 e[n].x1 = p[b].x * scale_x + shift_x;
10506 e[n].y1 = (p[b].y * y_scale_inv + shift_y) * (
float)vsubsample;
10513 nk_tt__sort_edges(e, n);
10515 nk_tt__rasterize_sorted_edges(result, e, n, vsubsample, off_x, off_y, alloc);
10520 nk_tt__add_point(
struct nk_tt__point *points,
int n,
float x,
float y)
10522 if (!points)
return;
10528 nk_tt__tesselate_curve(
struct nk_tt__point *points,
int *num_points,
10529 float x0,
float y0,
float x1,
float y1,
float x2,
float y2,
10530 float objspace_flatness_squared,
int n)
10535 float mx = (x0 + 2*x1 + x2)/4;
10536 float my = (y0 + 2*y1 + y2)/4;
10538 float dx = (x0+x2)/2 - mx;
10539 float dy = (y0+y2)/2 - my;
10544 if (dx*dx+dy*dy > objspace_flatness_squared) {
10545 nk_tt__tesselate_curve(points, num_points, x0,y0,
10546 (x0+x1)/2.0f,(y0+y1)/2.0f, mx,my, objspace_flatness_squared,n+1);
10547 nk_tt__tesselate_curve(points, num_points, mx,my,
10548 (x1+x2)/2.0f,(y1+y2)/2.0f, x2,y2, objspace_flatness_squared,n+1);
10550 nk_tt__add_point(points, *num_points,x2,y2);
10551 *num_points = *num_points+1;
10558 nk_tt_FlattenCurves(
struct nk_tt_vertex *vertices,
int num_verts,
10559 float objspace_flatness,
int **contour_lengths,
int *num_contours,
10562 struct nk_tt__point *points=0;
10564 float objspace_flatness_squared = objspace_flatness * objspace_flatness;
10571 for (i=0; i < num_verts; ++i)
10572 if (vertices[i].type == NK_TT_vmove) ++n;
10575 if (n == 0)
return 0;
10577 *contour_lengths = (
int *)
10578 alloc->
alloc(alloc->
userdata,0, (
sizeof(**contour_lengths) * (nk_size)n));
10579 if (*contour_lengths == 0) {
10585 for (pass=0; pass < 2; ++pass)
10589 points = (
struct nk_tt__point *)
10590 alloc->
alloc(alloc->
userdata,0, (nk_size)num_points *
sizeof(points[0]));
10591 if (points == 0)
goto error;
10596 for (i=0; i < num_verts; ++i)
10598 switch (vertices[i].type) {
10602 (*contour_lengths)[n] = num_points - start;
10604 start = num_points;
10606 x = vertices[i].x, y = vertices[i].y;
10607 nk_tt__add_point(points, num_points++, x,y);
10610 x = vertices[i].x, y = vertices[i].y;
10611 nk_tt__add_point(points, num_points++, x, y);
10614 nk_tt__tesselate_curve(points, &num_points, x,y,
10615 vertices[i].cx, vertices[i].cy,
10616 vertices[i].x, vertices[i].y,
10617 objspace_flatness_squared, 0);
10618 x = vertices[i].x, y = vertices[i].y;
10623 (*contour_lengths)[n] = num_points - start;
10630 *contour_lengths = 0;
10636 nk_tt_Rasterize(
struct nk_tt__bitmap *result,
float flatness_in_pixels,
10637 struct nk_tt_vertex *vertices,
int num_verts,
10638 float scale_x,
float scale_y,
float shift_x,
float shift_y,
10639 int x_off,
int y_off,
int invert,
struct nk_allocator *alloc)
10641 float scale = scale_x > scale_y ? scale_y : scale_x;
10642 int winding_count, *winding_lengths;
10643 struct nk_tt__point *windings = nk_tt_FlattenCurves(vertices, num_verts,
10644 flatness_in_pixels / scale, &winding_lengths, &winding_count, alloc);
10648 nk_tt__rasterize(result, windings, winding_lengths, winding_count,
10649 scale_x, scale_y, shift_x, shift_y, x_off, y_off, invert, alloc);
10656 nk_tt_MakeGlyphBitmapSubpixel(
const struct nk_tt_fontinfo *info,
unsigned char *output,
10657 int out_w,
int out_h,
int out_stride,
float scale_x,
float scale_y,
10658 float shift_x,
float shift_y,
int glyph,
struct nk_allocator *alloc)
10661 struct nk_tt_vertex *vertices;
10662 int num_verts = nk_tt_GetGlyphShape(info, alloc, glyph, &vertices);
10663 struct nk_tt__bitmap gbm;
10665 nk_tt_GetGlyphBitmapBoxSubpixel(info, glyph, scale_x, scale_y, shift_x,
10666 shift_y, &ix0,&iy0,0,0);
10670 gbm.stride = out_stride;
10672 if (gbm.w && gbm.h)
10673 nk_tt_Rasterize(&gbm, 0.35f, vertices, num_verts, scale_x, scale_y,
10674 shift_x, shift_y, ix0,iy0, 1, alloc);
10682 nk_tt_PackBegin(
struct nk_tt_pack_context *spc,
unsigned char *pixels,
10683 int pw,
int ph,
int stride_in_bytes,
int padding,
struct nk_allocator *alloc)
10685 int num_nodes = pw - padding;
10686 struct nk_rp_context *context = (
struct nk_rp_context *)
10688 struct nk_rp_node *nodes = (
struct nk_rp_node*)
10689 alloc->
alloc(alloc->
userdata,0, (
sizeof(*nodes ) * (nk_size)num_nodes));
10691 if (context == 0 || nodes == 0) {
10692 if (context != 0) alloc->
free(alloc->
userdata, context);
10699 spc->pixels = pixels;
10700 spc->pack_info = context;
10701 spc->nodes = nodes;
10702 spc->padding = padding;
10703 spc->stride_in_bytes = (stride_in_bytes != 0) ? stride_in_bytes : pw;
10704 spc->h_oversample = 1;
10705 spc->v_oversample = 1;
10707 nk_rp_init_target(context, pw-padding, ph-padding, nodes, num_nodes);
10709 NK_MEMSET(pixels, 0, (nk_size)(pw*ph));
10714 nk_tt_PackEnd(
struct nk_tt_pack_context *spc,
struct nk_allocator *alloc)
10721 nk_tt_PackSetOversampling(
struct nk_tt_pack_context *spc,
10722 unsigned int h_oversample,
unsigned int v_oversample)
10724 NK_ASSERT(h_oversample <= NK_TT_MAX_OVERSAMPLE);
10725 NK_ASSERT(v_oversample <= NK_TT_MAX_OVERSAMPLE);
10726 if (h_oversample <= NK_TT_MAX_OVERSAMPLE)
10727 spc->h_oversample = h_oversample;
10728 if (v_oversample <= NK_TT_MAX_OVERSAMPLE)
10729 spc->v_oversample = v_oversample;
10733 nk_tt__h_prefilter(
unsigned char *pixels,
int w,
int h,
int stride_in_bytes,
10736 unsigned char buffer[NK_TT_MAX_OVERSAMPLE];
10737 int safe_w = w - kernel_width;
10740 for (j=0; j < h; ++j)
10743 unsigned int total;
10744 NK_MEMSET(buffer, 0, (nk_size)kernel_width);
10749 switch (kernel_width) {
10751 for (i=0; i <= safe_w; ++i) {
10752 total += (
unsigned int)(pixels[i] - buffer[i & NK_TT__OVER_MASK]);
10753 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i];
10754 pixels[i] = (
unsigned char) (total / 2);
10758 for (i=0; i <= safe_w; ++i) {
10759 total += (
unsigned int)(pixels[i] - buffer[i & NK_TT__OVER_MASK]);
10760 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i];
10761 pixels[i] = (
unsigned char) (total / 3);
10765 for (i=0; i <= safe_w; ++i) {
10766 total += (
unsigned int)pixels[i] - buffer[i & NK_TT__OVER_MASK];
10767 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i];
10768 pixels[i] = (
unsigned char) (total / 4);
10772 for (i=0; i <= safe_w; ++i) {
10773 total += (
unsigned int)(pixels[i] - buffer[i & NK_TT__OVER_MASK]);
10774 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i];
10775 pixels[i] = (
unsigned char) (total / 5);
10779 for (i=0; i <= safe_w; ++i) {
10780 total += (
unsigned int)(pixels[i] - buffer[i & NK_TT__OVER_MASK]);
10781 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i];
10782 pixels[i] = (
unsigned char) (total / (
unsigned int)kernel_width);
10787 for (; i < w; ++i) {
10788 NK_ASSERT(pixels[i] == 0);
10789 total -= (
unsigned int)(buffer[i & NK_TT__OVER_MASK]);
10790 pixels[i] = (
unsigned char) (total / (
unsigned int)kernel_width);
10792 pixels += stride_in_bytes;
10797 nk_tt__v_prefilter(
unsigned char *pixels,
int w,
int h,
int stride_in_bytes,
10800 unsigned char buffer[NK_TT_MAX_OVERSAMPLE];
10801 int safe_h = h - kernel_width;
10804 for (j=0; j < w; ++j)
10807 unsigned int total;
10808 NK_MEMSET(buffer, 0, (nk_size)kernel_width);
10813 switch (kernel_width) {
10815 for (i=0; i <= safe_h; ++i) {
10816 total += (
unsigned int)(pixels[i*stride_in_bytes] - buffer[i & NK_TT__OVER_MASK]);
10817 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i*stride_in_bytes];
10818 pixels[i*stride_in_bytes] = (
unsigned char) (total / 2);
10822 for (i=0; i <= safe_h; ++i) {
10823 total += (
unsigned int)(pixels[i*stride_in_bytes] - buffer[i & NK_TT__OVER_MASK]);
10824 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i*stride_in_bytes];
10825 pixels[i*stride_in_bytes] = (
unsigned char) (total / 3);
10829 for (i=0; i <= safe_h; ++i) {
10830 total += (
unsigned int)(pixels[i*stride_in_bytes] - buffer[i & NK_TT__OVER_MASK]);
10831 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i*stride_in_bytes];
10832 pixels[i*stride_in_bytes] = (
unsigned char) (total / 4);
10836 for (i=0; i <= safe_h; ++i) {
10837 total += (
unsigned int)(pixels[i*stride_in_bytes] - buffer[i & NK_TT__OVER_MASK]);
10838 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i*stride_in_bytes];
10839 pixels[i*stride_in_bytes] = (
unsigned char) (total / 5);
10843 for (i=0; i <= safe_h; ++i) {
10844 total += (
unsigned int)(pixels[i*stride_in_bytes] - buffer[i & NK_TT__OVER_MASK]);
10845 buffer[(i+kernel_width) & NK_TT__OVER_MASK] = pixels[i*stride_in_bytes];
10846 pixels[i*stride_in_bytes] = (
unsigned char) (total / (
unsigned int)kernel_width);
10851 for (; i < h; ++i) {
10852 NK_ASSERT(pixels[i*stride_in_bytes] == 0);
10853 total -= (
unsigned int)(buffer[i & NK_TT__OVER_MASK]);
10854 pixels[i*stride_in_bytes] = (
unsigned char) (total / (
unsigned int)kernel_width);
10861 nk_tt__oversample_shift(
int oversample)
10870 return (
float)-(oversample - 1) / (2.0f * (
float)oversample);
10875 nk_tt_PackFontRangesGatherRects(
struct nk_tt_pack_context *spc,
10876 struct nk_tt_fontinfo *info,
struct nk_tt_pack_range *ranges,
10877 int num_ranges,
struct nk_rp_rect *rects)
10882 for (i=0; i < num_ranges; ++i) {
10883 float fh = ranges[i].font_size;
10884 float scale = (fh > 0) ? nk_tt_ScaleForPixelHeight(info, fh):
10885 nk_tt_ScaleForMappingEmToPixels(info, -fh);
10886 ranges[i].h_oversample = (
unsigned char) spc->h_oversample;
10887 ranges[i].v_oversample = (
unsigned char) spc->v_oversample;
10888 for (j=0; j < ranges[i].num_chars; ++j) {
10890 int codepoint = ranges[i].first_unicode_codepoint_in_range ?
10891 ranges[i].first_unicode_codepoint_in_range + j :
10892 ranges[i].array_of_unicode_codepoints[j];
10894 int glyph = nk_tt_FindGlyphIndex(info, codepoint);
10895 nk_tt_GetGlyphBitmapBoxSubpixel(info,glyph, scale * (
float)spc->h_oversample,
10896 scale * (
float)spc->v_oversample, 0,0, &x0,&y0,&x1,&y1);
10897 rects[k].w = (nk_rp_coord) (x1-x0 + spc->padding + (
int)spc->h_oversample-1);
10898 rects[k].h = (nk_rp_coord) (y1-y0 + spc->padding + (
int)spc->v_oversample-1);
10906 nk_tt_PackFontRangesRenderIntoRects(
struct nk_tt_pack_context *spc,
10907 struct nk_tt_fontinfo *info,
struct nk_tt_pack_range *ranges,
10908 int num_ranges,
struct nk_rp_rect *rects,
struct nk_allocator *alloc)
10910 int i,j,k, return_value = 1;
10912 int old_h_over = (
int)spc->h_oversample;
10913 int old_v_over = (
int)spc->v_oversample;
10917 for (i=0; i < num_ranges; ++i)
10919 float fh = ranges[i].font_size;
10920 float recip_h,recip_v,sub_x,sub_y;
10921 float scale = fh > 0 ? nk_tt_ScaleForPixelHeight(info, fh):
10922 nk_tt_ScaleForMappingEmToPixels(info, -fh);
10924 spc->h_oversample = ranges[i].h_oversample;
10925 spc->v_oversample = ranges[i].v_oversample;
10927 recip_h = 1.0f / (float)spc->h_oversample;
10928 recip_v = 1.0f / (
float)spc->v_oversample;
10930 sub_x = nk_tt__oversample_shift((
int)spc->h_oversample);
10931 sub_y = nk_tt__oversample_shift((
int)spc->v_oversample);
10933 for (j=0; j < ranges[i].num_chars; ++j)
10935 struct nk_rp_rect *r = &rects[k];
10938 struct nk_tt_packedchar *bc = &ranges[i].chardata_for_range[j];
10939 int advance, lsb, x0,y0,x1,y1;
10940 int codepoint = ranges[i].first_unicode_codepoint_in_range ?
10941 ranges[i].first_unicode_codepoint_in_range + j :
10942 ranges[i].array_of_unicode_codepoints[j];
10943 int glyph = nk_tt_FindGlyphIndex(info, codepoint);
10944 nk_rp_coord pad = (nk_rp_coord) spc->padding;
10947 r->x = (nk_rp_coord)((
int)r->x + (
int)pad);
10948 r->y = (nk_rp_coord)((
int)r->y + (
int)pad);
10949 r->w = (nk_rp_coord)((
int)r->w - (
int)pad);
10950 r->h = (nk_rp_coord)((
int)r->h - (
int)pad);
10952 nk_tt_GetGlyphHMetrics(info, glyph, &advance, &lsb);
10953 nk_tt_GetGlyphBitmapBox(info, glyph, scale * (
float)spc->h_oversample,
10954 (scale * (
float)spc->v_oversample), &x0,&y0,&x1,&y1);
10955 nk_tt_MakeGlyphBitmapSubpixel(info, spc->pixels + r->x + r->y*spc->stride_in_bytes,
10956 (
int)(r->w - spc->h_oversample+1), (
int)(r->h - spc->v_oversample+1),
10957 spc->stride_in_bytes, scale * (
float)spc->h_oversample,
10958 scale * (
float)spc->v_oversample, 0,0, glyph, alloc);
10960 if (spc->h_oversample > 1)
10961 nk_tt__h_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes,
10962 r->w, r->h, spc->stride_in_bytes, (
int)spc->h_oversample);
10964 if (spc->v_oversample > 1)
10965 nk_tt__v_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes,
10966 r->w, r->h, spc->stride_in_bytes, (
int)spc->v_oversample);
10969 bc->y0 = (nk_ushort) r->y;
10972 bc->xadvance = scale * (float)advance;
10973 bc->xoff = (float) x0 * recip_h + sub_x;
10974 bc->yoff = (float) y0 * recip_v + sub_y;
10975 bc->xoff2 = ((float)x0 + r->w) * recip_h + sub_x;
10976 bc->yoff2 = ((float)y0 + r->h) * recip_v + sub_y;
10984 spc->h_oversample = (
unsigned int)old_h_over;
10985 spc->v_oversample = (
unsigned int)old_v_over;
10986 return return_value;
10990 nk_tt_GetPackedQuad(
struct nk_tt_packedchar *chardata,
int pw,
int ph,
10991 int char_index,
float *xpos,
float *ypos,
struct nk_tt_aligned_quad *q,
10992 int align_to_integer)
10994 float ipw = 1.0f / (float)pw, iph = 1.0f / (
float)ph;
10995 struct nk_tt_packedchar *b = (
struct nk_tt_packedchar*)(chardata + char_index);
10996 if (align_to_integer) {
10997 int tx = nk_ifloorf((*xpos + b->xoff) + 0.5f);
10998 int ty = nk_ifloorf((*ypos + b->yoff) + 0.5f);
11000 float x = (float)tx;
11001 float y = (float)ty;
11005 q->x1 = x + b->xoff2 - b->xoff;
11006 q->y1 = y + b->yoff2 - b->yoff;
11008 q->x0 = *xpos + b->xoff;
11009 q->y0 = *ypos + b->yoff;
11010 q->x1 = *xpos + b->xoff2;
11011 q->y1 = *ypos + b->yoff2;
11013 q->s0 = b->x0 * ipw;
11014 q->t0 = b->y0 * iph;
11015 q->s1 = b->x1 * ipw;
11016 q->t1 = b->y1 * iph;
11017 *xpos += b->xadvance;
11025 struct nk_font_bake_data {
11026 struct nk_tt_fontinfo info;
11027 struct nk_rp_rect *rects;
11028 struct nk_tt_pack_range *ranges;
11029 nk_rune range_count;
11032 struct nk_font_baker {
11034 struct nk_tt_pack_context spc;
11035 struct nk_font_bake_data *build;
11036 struct nk_tt_packedchar *packed_chars;
11037 struct nk_rp_rect *rects;
11038 struct nk_tt_pack_range *ranges;
11048 nk_range_count(
const nk_rune *range)
11050 const nk_rune *iter = range;
11052 if (!range)
return 0;
11053 while (*(iter++) != 0);
11054 return (iter == range) ? 0 : (
int)((iter - range)/2);
11058 nk_range_glyph_count(
const nk_rune *range,
int count)
11061 int total_glyphs = 0;
11062 for (i = 0; i < count; ++i) {
11064 nk_rune f = range[(i*2)+0];
11065 nk_rune t = range[(i*2)+1];
11067 diff = (
int)((t - f) + 1);
11068 total_glyphs += diff;
11070 return total_glyphs;
11074 nk_font_default_glyph_ranges(
void)
11076 NK_STORAGE const nk_rune ranges[] = {0x0020, 0x00FF, 0};
11081 nk_font_chinese_glyph_ranges(
void)
11095 nk_font_cyrillic_glyph_ranges(
void)
11108 nk_font_korean_glyph_ranges(
void)
11120 nk_font_baker_memory(nk_size *temp,
int *glyph_count,
11121 struct nk_font_config *config_list,
int count)
11123 int range_count = 0;
11124 int total_range_count = 0;
11125 struct nk_font_config *iter;
11127 NK_ASSERT(config_list);
11128 NK_ASSERT(glyph_count);
11129 if (!config_list) {
11136 if (!config_list->range)
11137 config_list->range = nk_font_default_glyph_ranges();
11138 for (iter = config_list; iter; iter = iter->next) {
11139 range_count = nk_range_count(iter->range);
11140 total_range_count += range_count;
11141 *glyph_count += nk_range_glyph_count(iter->range, range_count);
11144 *temp = (
nk_size)*glyph_count *
sizeof(
struct nk_rp_rect);
11145 *temp += (
nk_size)total_range_count *
sizeof(
struct nk_tt_pack_range);
11146 *temp += (
nk_size)*glyph_count *
sizeof(
struct nk_tt_packedchar);
11147 *temp += (
nk_size)count *
sizeof(
struct nk_font_bake_data);
11148 *temp +=
sizeof(
struct nk_font_baker);
11149 *temp += nk_rect_align + nk_range_align + nk_char_align;
11150 *temp += nk_build_align + nk_baker_align;
11154 nk_font_baker(
void *memory,
int glyph_count,
int count,
struct nk_allocator *alloc)
11156 struct nk_font_baker *baker;
11157 if (!memory)
return 0;
11159 baker = (
struct nk_font_baker*)
NK_ALIGN_PTR(memory, nk_baker_align);
11160 baker->build = (
struct nk_font_bake_data*)
NK_ALIGN_PTR((baker + 1), nk_build_align);
11161 baker->packed_chars = (
struct nk_tt_packedchar*)
NK_ALIGN_PTR((baker->build + count), nk_char_align);
11162 baker->rects = (
struct nk_rp_rect*)
NK_ALIGN_PTR((baker->packed_chars + glyph_count), nk_rect_align);
11163 baker->ranges = (
struct nk_tt_pack_range*)
NK_ALIGN_PTR((baker->rects + glyph_count), nk_range_align);
11164 baker->alloc = *alloc;
11169 nk_font_bake_pack(
struct nk_font_baker *baker,
11170 nk_size *image_memory,
int *width,
int *height,
struct nk_recti *custom,
11171 const struct nk_font_config *config_list,
int count,
11174 NK_STORAGE const nk_size max_height = 1024 * 32;
11175 const struct nk_font_config *config_iter;
11176 int total_glyph_count = 0;
11177 int total_range_count = 0;
11178 int range_count = 0;
11181 NK_ASSERT(image_memory);
11184 NK_ASSERT(config_list);
11188 if (!image_memory || !width || !height || !config_list || !count)
return nk_false;
11189 for (config_iter = config_list; config_iter; config_iter = config_iter->next) {
11190 range_count = nk_range_count(config_iter->range);
11191 total_range_count += range_count;
11192 total_glyph_count += nk_range_glyph_count(config_iter->range, range_count);
11196 for (config_iter = config_list; config_iter; config_iter = config_iter->next) {
11197 const struct nk_font_config *cfg = config_iter;
11198 if (!nk_tt_InitFont(&baker->build[i++].info, (
const unsigned char*)cfg->ttf_blob, 0))
11203 *width = (total_glyph_count > 1000) ? 1024 : 512;
11204 nk_tt_PackBegin(&baker->spc, 0, (
int)*width, (
int)max_height, 0, 1, alloc);
11213 struct nk_rp_rect custom_space;
11214 nk_zero(&custom_space,
sizeof(custom_space));
11215 custom_space.w = (nk_rp_coord)((custom->
w * 2) + 1);
11216 custom_space.h = (nk_rp_coord)(custom->
h + 1);
11218 nk_tt_PackSetOversampling(&baker->spc, 1, 1);
11219 nk_rp_pack_rects((
struct nk_rp_context*)baker->spc.pack_info, &custom_space, 1);
11220 *height =
NK_MAX(*height, (
int)(custom_space.y + custom_space.h));
11222 custom->
x = (short)custom_space.x;
11223 custom->
y = (
short)custom_space.y;
11224 custom->
w = (short)custom_space.w;
11225 custom->
h = (
short)custom_space.h;
11229 for (input_i = 0, config_iter = config_list; input_i < count && config_iter;
11230 input_i++, config_iter = config_iter->next)
11234 const nk_rune *in_range;
11235 const struct nk_font_config *cfg = config_iter;
11236 struct nk_font_bake_data *tmp = &baker->build[input_i];
11239 glyph_count = 0; range_count = 0;
11240 for (in_range = cfg->range; in_range[0] && in_range[1]; in_range += 2) {
11241 glyph_count += (
int)(in_range[1] - in_range[0]) + 1;
11246 tmp->ranges = baker->ranges + range_n;
11247 tmp->range_count = (
nk_rune)range_count;
11248 range_n += range_count;
11249 for (i = 0; i < range_count; ++i) {
11250 in_range = &cfg->range[i * 2];
11251 tmp->ranges[i].font_size = cfg->size;
11252 tmp->ranges[i].first_unicode_codepoint_in_range = (
int)in_range[0];
11253 tmp->ranges[i].num_chars = (
int)(in_range[1]- in_range[0]) + 1;
11254 tmp->ranges[i].chardata_for_range = baker->packed_chars + char_n;
11255 char_n += tmp->ranges[i].num_chars;
11259 tmp->rects = baker->rects + rect_n;
11260 rect_n += glyph_count;
11261 nk_tt_PackSetOversampling(&baker->spc, cfg->oversample_h, cfg->oversample_v);
11262 n = nk_tt_PackFontRangesGatherRects(&baker->spc, &tmp->info,
11263 tmp->ranges, (
int)tmp->range_count, tmp->rects);
11264 nk_rp_pack_rects((
struct nk_rp_context*)baker->spc.pack_info, tmp->rects, (
int)n);
11267 for (i = 0; i < n; ++i) {
11268 if (tmp->rects[i].was_packed)
11269 *height =
NK_MAX(*height, tmp->rects[i].y + tmp->rects[i].h);
11272 NK_ASSERT(rect_n == total_glyph_count);
11273 NK_ASSERT(char_n == total_glyph_count);
11274 NK_ASSERT(range_n == total_range_count);
11276 *height = (
int)nk_round_up_pow2((nk_uint)*height);
11282 nk_font_bake(
struct nk_font_baker *baker,
void *image_memory,
int width,
int height,
11283 struct nk_font_glyph *glyphs,
int glyphs_count,
11284 const struct nk_font_config *config_list,
int font_count)
11287 nk_rune glyph_n = 0;
11288 const struct nk_font_config *config_iter;
11290 NK_ASSERT(image_memory);
11293 NK_ASSERT(config_list);
11295 NK_ASSERT(font_count);
11296 NK_ASSERT(glyphs_count);
11297 if (!image_memory || !width || !height || !config_list ||
11298 !font_count || !glyphs || !glyphs_count)
11302 nk_zero(image_memory, (nk_size)((nk_size)width * (nk_size)height));
11303 baker->spc.pixels = (
unsigned char*)image_memory;
11304 baker->spc.height = (
int)height;
11305 for (input_i = 0, config_iter = config_list; input_i < font_count && config_iter;
11306 ++input_i, config_iter = config_iter->next)
11308 const struct nk_font_config *cfg = config_iter;
11309 struct nk_font_bake_data *tmp = &baker->build[input_i];
11310 nk_tt_PackSetOversampling(&baker->spc, cfg->oversample_h, cfg->oversample_v);
11311 nk_tt_PackFontRangesRenderIntoRects(&baker->spc, &tmp->info, tmp->ranges,
11312 (
int)tmp->range_count, tmp->rects, &baker->alloc);
11314 nk_tt_PackEnd(&baker->spc, &baker->alloc);
11317 for (input_i = 0, config_iter = config_list; input_i < font_count && config_iter;
11318 ++input_i, config_iter = config_iter->next)
11322 nk_rune glyph_count = 0;
11323 const struct nk_font_config *cfg = config_iter;
11324 struct nk_font_bake_data *tmp = &baker->build[input_i];
11325 struct nk_baked_font *dst_font = cfg->font;
11327 float font_scale = nk_tt_ScaleForPixelHeight(&tmp->info, cfg->size);
11328 int unscaled_ascent, unscaled_descent, unscaled_line_gap;
11329 nk_tt_GetFontVMetrics(&tmp->info, &unscaled_ascent, &unscaled_descent,
11330 &unscaled_line_gap);
11333 if (!cfg->merge_mode) {
11334 dst_font->ranges = cfg->range;
11335 dst_font->height = cfg->size;
11336 dst_font->ascent = ((float)unscaled_ascent * font_scale);
11337 dst_font->descent = ((float)unscaled_descent * font_scale);
11338 dst_font->glyph_offset = glyph_n;
11342 for (i = 0; i < tmp->range_count; ++i)
11344 struct nk_tt_pack_range *range = &tmp->ranges[i];
11345 for (char_idx = 0; char_idx < range->num_chars; char_idx++)
11347 nk_rune codepoint = 0;
11348 float dummy_x = 0, dummy_y = 0;
11349 struct nk_tt_aligned_quad q;
11350 struct nk_font_glyph *glyph;
11353 const struct nk_tt_packedchar *pc = &range->chardata_for_range[char_idx];
11354 if (!pc->x0 && !pc->x1 && !pc->y0 && !pc->y1)
continue;
11355 codepoint = (
nk_rune)(range->first_unicode_codepoint_in_range + char_idx);
11356 nk_tt_GetPackedQuad(range->chardata_for_range, (
int)width,
11357 (
int)height, char_idx, &dummy_x, &dummy_y, &q, 0);
11360 glyph = &glyphs[dst_font->glyph_offset + (
unsigned int)glyph_count];
11361 glyph->codepoint = codepoint;
11362 glyph->x0 = q.x0; glyph->y0 = q.y0;
11363 glyph->x1 = q.x1; glyph->y1 = q.y1;
11364 glyph->y0 += (dst_font->ascent + 0.5f);
11365 glyph->y1 += (dst_font->ascent + 0.5f);
11366 glyph->w = glyph->x1 - glyph->x0 + 0.5f;
11367 glyph->h = glyph->y1 - glyph->y0;
11369 if (cfg->coord_type == NK_COORD_PIXEL) {
11370 glyph->u0 = q.s0 * (float)width;
11371 glyph->v0 = q.t0 * (float)height;
11372 glyph->u1 = q.s1 * (float)width;
11373 glyph->v1 = q.t1 * (float)height;
11380 glyph->xadvance = (pc->xadvance + cfg->spacing.x);
11381 if (cfg->pixel_snap)
11382 glyph->xadvance = (float)(
int)(glyph->xadvance + 0.5f);
11386 dst_font->glyph_count = glyph_count;
11387 glyph_n += dst_font->glyph_count;
11392 nk_font_bake_custom_data(
void *img_memory,
int img_width,
int img_height,
11393 struct nk_recti img_dst,
const char *texture_data_mask,
int tex_width,
11394 int tex_height,
char white,
char black)
11401 NK_ASSERT(img_memory);
11402 NK_ASSERT(img_width);
11403 NK_ASSERT(img_height);
11404 NK_ASSERT(texture_data_mask);
11406 if (!img_memory || !img_width || !img_height || !texture_data_mask)
11409 pixels = (nk_byte*)img_memory;
11410 for (y = 0, n = 0; y < tex_height; ++y) {
11411 for (x = 0; x < tex_width; ++x, ++n) {
11412 const int off0 = ((img_dst.
x + x) + (img_dst.
y + y) * img_width);
11413 const int off1 = off0 + 1 + tex_width;
11414 pixels[off0] = (texture_data_mask[n] == white) ? 0xFF : 0x00;
11415 pixels[off1] = (texture_data_mask[n] == black) ? 0xFF : 0x00;
11421 nk_font_bake_convert(
void *out_memory,
int img_width,
int img_height,
11422 const void *in_memory)
11426 const nk_byte *src;
11428 NK_ASSERT(out_memory);
11429 NK_ASSERT(in_memory);
11430 NK_ASSERT(img_width);
11431 NK_ASSERT(img_height);
11432 if (!out_memory || !in_memory || !img_height || !img_width)
return;
11434 dst = (nk_rune*)out_memory;
11435 src = (
const nk_byte*)in_memory;
11436 for (n = (
int)(img_width * img_height); n > 0; n--)
11437 *dst++ = ((nk_rune)(*src++) << 24) | 0x00FFFFFF;
11446 nk_font_text_width(nk_handle handle,
float height,
const char *text,
int len)
11450 float text_width = 0;
11454 struct nk_font *font = (
struct nk_font*)handle.
ptr;
11456 NK_ASSERT(font->glyphs);
11457 if (!font || !text || !len)
11460 scale = height/font->info.height;
11461 glyph_len = text_len =
nk_utf_decode(text, &unicode, (
int)len);
11462 if (!glyph_len)
return 0;
11463 while (text_len <= (
int)len && glyph_len) {
11464 const struct nk_font_glyph *g;
11468 g = nk_font_find_glyph(font, unicode);
11469 text_width += g->xadvance * scale;
11472 glyph_len =
nk_utf_decode(text + text_len, &unicode, (
int)len - text_len);
11473 text_len += glyph_len;
11478 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
11480 nk_font_query_font_glyph(nk_handle handle,
float height,
11481 struct nk_user_font_glyph *glyph, nk_rune codepoint, nk_rune next_codepoint)
11484 const struct nk_font_glyph *g;
11485 struct nk_font *font;
11490 font = (
struct nk_font*)handle.
ptr;
11492 NK_ASSERT(font->glyphs);
11493 if (!font || !glyph)
11496 scale = height/font->info.height;
11497 g = nk_font_find_glyph(font, codepoint);
11498 glyph->width = (g->x1 - g->x0) * scale;
11499 glyph->height = (g->y1 - g->y0) * scale;
11500 glyph->offset =
nk_vec2(g->x0 * scale, g->y0 * scale);
11501 glyph->xadvance = (g->xadvance * scale);
11502 glyph->uv[0] =
nk_vec2(g->u0, g->v0);
11503 glyph->uv[1] =
nk_vec2(g->u1, g->v1);
11507 NK_API const struct nk_font_glyph*
11508 nk_font_find_glyph(
struct nk_font *font, nk_rune unicode)
11512 int total_glyphs = 0;
11513 const struct nk_font_glyph *glyph = 0;
11516 NK_ASSERT(font->glyphs);
11517 NK_ASSERT(font->info.ranges);
11518 if (!font || !font->glyphs)
return 0;
11520 glyph = font->fallback;
11521 count = nk_range_count(font->info.ranges);
11522 for (i = 0; i < count; ++i) {
11524 nk_rune f = font->info.ranges[(i*2)+0];
11525 nk_rune t = font->info.ranges[(i*2)+1];
11526 diff = (
int)((t - f) + 1);
11527 if (unicode >= f && unicode <= t)
11528 return &font->glyphs[((
nk_rune)total_glyphs + (unicode - f))];
11529 total_glyphs += diff;
11535 nk_font_init(
struct nk_font *font,
float pixel_height,
11536 nk_rune fallback_codepoint,
struct nk_font_glyph *glyphs,
11537 const struct nk_baked_font *baked_font, nk_handle atlas)
11539 struct nk_baked_font baked;
11542 NK_ASSERT(baked_font);
11543 if (!font || !glyphs || !baked_font)
11546 baked = *baked_font;
11547 font->info = baked;
11548 font->scale = (float)pixel_height / (
float)font->info.height;
11549 font->glyphs = &glyphs[baked_font->glyph_offset];
11550 font->texture = atlas;
11551 font->fallback_codepoint = fallback_codepoint;
11552 font->fallback = nk_font_find_glyph(font, fallback_codepoint);
11554 font->handle.height = font->info.height * font->scale;
11555 font->handle.width = nk_font_text_width;
11556 font->handle.userdata.ptr = font;
11557 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
11558 font->handle.query = nk_font_query_font_glyph;
11559 font->handle.texture = font->texture;
11572 #ifdef NK_INCLUDE_DEFAULT_FONT
11575 #pragma clang diagnostic push
11577 #pragma clang diagnostic ignored "-Woverlength-strings"
11578 #elif defined(__GNUC__) || defined(__GNUG__)
11579 #pragma GCC diagnostic push
11580 #pragma GCC diagnostic ignored "-Woverlength-strings"
11583 NK_GLOBAL const char nk_proggy_clean_ttf_compressed_data_base85[11980+1] =
11584 "7])#######hV0qs'/###[),##/l:$#Q6>##5[n42>c-TH`->>#/e>11NNV=Bv(*:.F?uu#(gRU.o0XGH`$vhLG1hxt9?W`#,5LsCp#-i>.r$<$6pD>Lb';9Crc6tgXmKVeU2cD4Eo3R/"
11585 "2*>]b(MC;$jPfY.;h^`IWM9<Lh2TlS+f-s$o6Q<BWH`YiU.xfLq$N;$0iR/GX:U(jcW2p/W*q?-qmnUCI;jHSAiFWM.R*kU@C=GH?a9wp8f$e.-4^Qg1)Q-GL(lf(r/7GrRgwV%MS=C#"
11586 "`8ND>Qo#t'X#(v#Y9w0#1D$CIf;W'#pWUPXOuxXuU(H9M(1<q-UE31#^-V'8IRUo7Qf./L>=Ke$$'5F%)]0^#0X@U.a<r:QLtFsLcL6##lOj)#.Y5<-R&KgLwqJfLgN&;Q?gI^#DY2uL"
11587 "i@^rMl9t=cWq6##weg>$FBjVQTSDgEKnIS7EM9>ZY9w0#L;>>#Mx&4Mvt//L[MkA#W@lK.N'[0#7RL_&#w+F%HtG9M#XL`N&.,GM4Pg;-<nLENhvx>-VsM.M0rJfLH2eTM`*oJMHRC`N"
11588 "kfimM2J,W-jXS:)r0wK#@Fge$U>`w'N7G#$#fB#$E^$#:9:hk+eOe--6x)F7*E%?76%^GMHePW-Z5l'&GiF#$956:rS?dA#fiK:)Yr+`�j@'DbG&#^$PG.Ll+DNa<XCMKEV*N)LN/N"
11589 "*b=%Q6pia-Xg8I$<MR&,VdJe$<(7G;Ckl'&hF;;$<_=X(b.RS%%)###MPBuuE1V:v&cXm#(&cV]`k9OhLMbn%s$G2,B$BfD3X*sp5#l,$R#]x_X1xKX%b5U*[r5iMfUo9U`N99hG)"
11590 "tm+/Us9pG)XPu`<0s-)WTt(gCRxIg(%6sfh=ktMKn3j)<6<b5Sk_/0(^]AaN#(p/L>&VZ>1i%h1S9u5o@YaaW$e+b<TWFn/Z:Oh(Cx2$lNEoN^e)#CFY@@I;BOQ*sRwZtZxRcU7uW6CX"
11591 "ow0i(?$Q[cjOd[P4d)]>ROPOpxTO7Stwi1::iB1q)C_=dV26J;2,]7op$]uQr@_V7$q^%lQwtuHY]=DX,n3L#0PHDO4f9>dC@O>HBuKPpP*E,N+b3L#lpR/MrTEH.IAQk.a>D[.e;mc."
11592 "x]Ip.PH^'/aqUO/$1WxLoW0[iLA<QT;5HKD+@qQ'NQ(3_PLhE48R.qAPSwQ0/WK?Z,[x?-J;jQTWA0X@KJ(_Y8N-:/M74:/-ZpKrUss?d#dZq]DAbkU*JqkL+nwX@@47`5>w=4h(9.`G"
11593 "CRUxHPeR`5Mjol(dUWxZa(>STrPkrJiWx`5U7F#.g*jrohGg`cg:lSTvEY/EV_7H4Q9[Z%cnv;JQYZ5q.l7Zeas:HOIZOB?G<Nald$qs]@]L<J7bR*>gv:[7MI2k).'2($5FNP&EQ(,)"
11594 "U]W]+fh18.vsai00);D3@4ku5P?DP8aJt+;qUM]=+b'8@;mViBKx0DE[-auGl8:PJ&Dj+M6OC]O^((##]`0i)drT;-7X`=-H3[igUnPG-NZlo.#k@h#=Ork$m>a>$-?Tm$UV(?#P6YY#"
11595 "'/###xe7q.73rI3*pP/$1>s9)W,JrM7SN]'/4C#v$U`0#V.[0>xQsH$fEmPMgY2u7Kh(G%siIfLSoS+MK2eTM$=5,M8p`A.;_R%#u[K#$x4AG8.kK/HSB==-'Ie/QTtG?-.*^N-4B/ZM"
11596 "_3YlQC7(p7q)&](`6_c)$/*JL(L-^(]$wIM`dPtOdGA,U3:w2M-0<q-]L_?^)1vw'.,MRsqVr.L;aN&#/EgJ)PBc[-f>+WomX2u7lqM2iEumMTcsF?-aT=Z-97UEnXglEn1K-bnEO`gu"
11597 "Ft(c%=;Am_Qs@jLooI&NX;]0#j4#F14;gl8-GQpgwhrq8'=l_f-b49'UOqkLu7-##oDY2L(te+Mch&gLYtJ,MEtJfLh'x'M=$CS-ZZ%P]8bZ>#S?YY#%Q&q'3^Fw&?D)UDNrocM3A76/"
11598 "/oL?#h7gl85[qW/NDOk%16ij;+:1a'iNIdb-ou8.P*w,v5#EI$TWS>Pot-R*H'-SEpA:g)f+O$%%`kA#G=8RMmG1&O`>to8bC]T&$,n.LoO>29sp3dt-52U%VM#q7'DHpg+#Z9%H[K<L"
11599 "%a2E-grWVM3@2=-k22tL]4$##6We'8UJCKE[d_=%wI;'6X-GsLX4j^SgJ$##R*w,vP3wK#iiW&#*h^D&R?jp7+/u&#(AP##XU8c$fSYW-J95_-Dp[g9wcO&#M-h1OcJlc-*vpw0xUX&#"
11600 "OQFKNX@QI'IoPp7nb,QU//MQ&ZDkKP)X<WSVL(68uVl&#c'[0#(s1X&xm$Y%B7*K:eDA323j998GXbA#pwMs-jgD$9QISB-A_(aN4xoFM^@C58D0+Q+q3n0#3U1InDjF682-SjMXJK)("
11601 "h$hxua_K]ul92%'BOU&#BRRh-slg8KDlr:%L71Ka:.A;%YULjDPmL<LYs8i#XwJOYaKPKc1h:'9Ke,g)b),78=I39B;xiY$bgGw-&.Zi9InXDuYa%G*f2Bq7mn9^#p1vv%#(Wi-;/Z5h"
11602 "o;#2:;%d	v68C5g?ntX0X)pT`;%pB3q7mgGN)3%(P8nTd5L7GeA-GL@+%J3u2:(Yf>et`e;)f#Km8&+DC$I46>#Kr]]u-[=99tts1.qb#q72g1WJO81q+eN'03'eM>&1XxY-caEnO"
11603 "j%2n8)),?ILR5^.Ibn<-X-Mq7[a82Lq:F&#ce+S9wsCK*x`569E8ew'He]h:sI[2LM$[guka3ZRd6:t%IG:;$%YiJ:Nq=?eAw;/:nnDq0(CYcMpG)qLN4$##&J<j$UpK<Q4a1]MupW^-"
11604 "sj_$%[HK%'F####QRZJ::Y3EGl4'@%FkiAOg#p[##O`gukTfBHagL<LHw%q&OV0##F=6/:chIm0@eCP8X]:kFI%hl8hgO@RcBhS-@Qb$%+m=hPDLg*%K8ln(wcf3/'DW-$.lR?n[nCH-"
11605 "eXOONTJlh:.RYF%3'p6sq:UIMA945&^HFS87@$EP2iG<-lCO$%c`uKGD3rC$x0BL8aFn--`ke%#HMP'vh1/R&O_J9'um,.<tx[@%wsJk&bUT2`0uMv7gg#qp/ij.L56'hl;.s5CUrxjO"
11606 "M7-##.l+Au'A&O:-T72L]P`&=;ctp'XScX*rU.>-XTt,%OVU4)S1+R-#dg0/Nn?Ku1^0f$B*P:Rowwm-`0PKjYDDM'3]d39VZHEl4,.j']Pk-M.h^&:0FACm$maq-&sgw0t7/6(^xtk%"
11607 "LuH88Fj-ekm>GA#_>568x6(OFRl-IZp`&b,_P'$M<Jnq79VsJW/mWS*PUiq76;]/NM_>hLbxfc$mj`,O;&%W2m`Zh:/)Uetw:aJ%]K9h:TcF]u_-Sj9,VK3M.*'&0D[Ca]J9gp8,kAW]"
11608 "%(?A%R$f<->Zts'^kn=-^@c4%-pY6qI%J%1IGxfLU9CP8cbPlXv);C=b),<2mOvP8up,UVf3839acAWAW-W?#ao/^#%KYo8fRULNd2.>%m]UK:n%r$'sw]J;5pAoO_#2mO3n,'=H5(et"
11609 "Hg*`+RLgv>=4U8guD$I%D:W>-r5V*%j*W:Kvej.Lp$<M-SGZ':+Q_k+uvOSLiEo(<aD/K<CCc`'Lx>'?;++O'>()jLR-^u68PHm8ZFWe+ej8h:9r6L*0//c&iH&R8pRbA#Kjm%upV1g:"
11610 "a_#Ur7FuA#(tRh#.Y5K+@?3<-8m0$PEn;J:rh6?I6uG<-`wMU'ircp0LaE_OtlMb&1#6T.#FDKu#1Lw%u%+GM+X'e?YLfjM[VO0MbuFp7;>Q&#WIo)0@F%q7c#4XAXN-U&VB<HFF*qL("
11611 "$/V,;(kXZejWO`<[5?\?ewY(*9=%wDc;,u<'9t3W-(H1th3+G]ucQ]kLs7df($/*JL]@*t7Bu_G3_7mp7<iaQjO@.kLg;x3B0lqp7Hf,^Ze7-##@/c58Mo(3;knp0%)A7?-W+eI'o8)b<"
11612 "nKnw'Ho8C=Y>pqB>0ie&jhZ[?iLR@@_AvA-iQC(=ksRZRVp7`.=+NpBC%rh&3]R:8XDmE5^V8O(x<<aG/1N$#FX$0V5Y6x'aErI3I$7x%E`v<-BY,)%-?Psf*l?%C3.mM(=/M0:JxG'?"
11613 "7WhH%o'a<-80g0NBxoO(GH<dM]n.+%q@jH?f.UsJ2Ggs&4<-e47&Kl+f//9@`b+?.TeN_&B8Ss?v;^Trk;f#YvJkl&w$]>-+k?'(<S:68tq*WoDfZu';mM?8X[ma8W%*`-=;D.(nc7/;"
11614 ")g:T1=^J$&BRV(-lTmNB6xqB[@0*o.erM*<SWF]u2=st-*(6v>^](H.aREZSi,#1:[IXaZFOm<-ui#qUq2$##Ri;u75OK#(RtaW-K-F`S+cF]uN`-KMQ%rP/Xri.LRcB##=YL3BgM/3M"
11615 "D?@f&1'BW-)Ju<L25gl8uhVm1hL$##*8###'A3/LkKW+(^rWX?5W_8g)a(m&K8P>#bmmWCMkk&#TR`C,5d>g)F;t,4:@_l8G/5h4vUd%&%950:VXD'QdWoY-F$BtUwmfe$YqL'8(PWX("
11616 "P?^@Po3$##`MSs?DWBZ/S>+4%>fX,VWv/w'KD`LP5IbH;rTV>n3cEK8U#bX]l-/V+^lj3;vlMb&[5YQ8#pekX9JP3XUC72L,,?+Ni&co7ApnO*5NK,((W-i:$,kp'UDAO(G0Sq7MVjJs"
11617 "bIu)'Z,*[>br5fX^:FPAWr-m2KgL<LUN098kTF&#lvo58=/vjDo;.;)Ka*hLR#/k=rKbxuV`>Q_nN6'8uTGT5g)uLv:873UpTLgH+#FgpH'_o1780Ph8KmxQJ8#H72L4@768@Tm&Q"
11618 "h4CB/5OvmA&,Q&QbUoi$a_%3M01H)4x7I^&KQVgtFnV+;[Pc>[m4k//,]1?#`VY[Jr*3&&slRfLiVZJ:]?=K3Sw=[$=uRB?3xk48@aeg<Z'<$#4H)6,>e0jT6'N#(q%.O=?2S]u*(m<-"
11619 "V8J'(1)G][68hW$5'q[GC&5j`TE?m'esFGNRM)j,ffZ?-qx8;->g4t*:CIP/[Qap7/9'#(1sao7w-.qNUdkJ)tCF&#B^;xGvn2r9FEPFFFcL@.iFNkTve$m%#QvQS8U@)2Z+3K:AKM5i"
11620 "sZ88+dKQ)W6>J%CL<KE>`.d*(B`-n8D9oK<Up]c$X$(,)M8Zt7/[rdkqTgl-0cuGMv'?>-XV1q['-5k'cAZ69e;D_?$ZPP&s^+7])$*$#@QYi9,5P	r+$%CE=68>K8r0=dSC%%(@p7"
11621 ".m7jilQ02'0-VWAg<a/''3u.=4L$Y)6k/K:_[3=&jvL<L0C/2'v:^;-DIBW,B4E68:kZ;%?8(Q8BH=kO65BW?xSG&#@uU,DS*,?.+(o(#1vCS8#CHF>TlGW'b)Tq7VT9q^*^$$.:&N@@"
11622 "$&)WHtPm*5_rO0&e%K&#-30j(E4#'Zb.o/(Tpm$>K'f@[PvFl,hfINTNU6u'0pao7%XUp9]5.>%h`8_=VYbxuel.NTSsJfLacFu3B'lQSu/m6-Oqem8T+oE--$0a/k]uj9EwsG>%veR*"
11623 "hv^BFpQj:K'#SJ,sB-'#](j.Lg92rTw-*n%@/;39rrJF,l#qV%OrtBeC6/,;qB3ebNW[?,Hqj2L.1NP&GjUR=1D8QaS3Up&@*9wP?+lo7b?@%'k4`p0Z$22%K3+iCZj?XJN4Nm&+YF]u"
11624 "@-W$U%VEQ/,,>>#)D<h#`)h0:<Q6909ua+&VU%n2:cG3FJ-%@Bj-DgLr`Hw&HAKjKjseK</xKT*)B,N9X3]krc12t'pgTV(Lv-tL[xg_%=M_q7a^x?7Ubd>#%8cY#YZ?=,`Wdxu/ae&#"
11625 "w6)R89tI#6@s'(6Bf7a&?S=^ZI_kS&ai`&=tE72L_D,;^R)7[$s<Eh#c&)q.MXI%#v9ROa5FZO%sF7q7Nwb&#ptUJ:aqJe$Sl68%.D###EC><?-aF&#RNQv>o8lKN%5/$(vdfq7+ebA#"
11626 "u1p]ovUKW&Y%q]'>$1@-[xfn$7ZTp7mM,G,Ko7a&Gu%G[RMxJs[0MM%wci.LFDK)(<c`Q8N)jEIF*+?P2a8g%)$q]o2aH8C&<SibC/q,(e:v;-b#6[$NtDZ84Je2KNvB#$P5?tQ3nt(0"
11627 "d=j.LQf./Ll33+(;q3L-w=8dX$#WF&uIJ@-bfI>%:_i2B5CsR8&9Z&#=mPEnm0f`<&c)QL5uJ#%u%lJj+D-r;BoFDoS97h5g)E#o:&S4weDF,9^Hoe`h*L+_a*NrLW-1pG_&2UdB8"
11628 "6e%B/:=>)N4xeW.*wft-;$'58-ESqr<b?UI(_%@[P46>#U`'6AQ]m&6/`Z>#S?YY#Vc;r7U2&326d=w&H####?TZ`*4?&.MK?LP8Vxg>$[QXc%QJv92.(Db*B)gb*BM9dM*hJMAo*c&#"
11629 "b0v=Pjer]$gG&JXDf->'StvU7505l9$AFvgYRI^&<^b68?j#q9QX4SM'RO#&sL1IM.rJfLUAj221]d##DW=m83u5;'bYx,*Sl0hL(W;;$doB&O/TQ:(Z^xBdLjL<Lni;''X.`$#8+1GD"
11630 ":k$YUWsbn8ogh6rxZ2Z9]%nd+>V#*8U_72Lh+2Q8Cj0i:6hp&$C/:p(HK>T8Y[gHQ4`4)'$Ab(Nof%V'8hL&#<NEdtg(n'=S1A(Q1/I&4([%dM`,Iu'1:_hL>SfD07&6D<fp8dHM7/g+"
11631 "tlPN9J*rKaPct&?'uBCem^jn%9_K)<,C5K3s=5g&GmJb*[SYq7K;TRLGCsM-$$;S%:Y@r7AK0pprpL<Lrh,q7e/%KWK:50I^+m'vi`3?%Zp+<-d+$L-Sv:@.o19n$s0&39;kn;S%BSq*"
11632 "$3WoJSCLweV[aZ'MQIjO<7;X-X;&+dMLvu#^UsGEC9WEc[X(wI7#2.(F0jV*eZf<-Qv3J-c+J5AlrB#$p(H68LvEA'q3n0#m,[`*8Ft)FcYgEud]CWfm68,(aLA$@EFTgLXoBq/UPlp7"
11633 ":d[/;r_ix=:TF`S5H-b<LI&HY(K=h#)]Lk$K14lVfm:x$H<3^Ql<M`$OhapBnkup'D#L$Pb_`N*g]2e;X/Dtg,bsj&K#2[-:iYr'_wgH)NUIR8a1n#S?Yej'h8^58UbZd+^FKD*T@;6A"
11634 "7aQC[K8d-(v6GI$x:T<&'Gp5Uf>@M.*J:;$-rv29'M]8qMv-tLp,'886iaC=Hb*YJoKJ,(j%K=H`K.v9HggqBIiZu'QvBT.#=)0ukruV&.)3=(^1`o*Pj4<-<aN((^7('#Z0wK#5GX@7"
11635 "u][`*S^43933A4rl][`*O4CgLEl]v$1Q3AeF37dbXk,.)vj#x'd`;qgbQR%FW,2(?LO=s%Sc68%NP'##Aotl8x=BE#j1UD([3$M(]UI2LX3RpKN@;/#f'f/&_mt&F)XdF<9t4)Qa.*kT"
11636 "LwQ'(TTB9.xH'>#MJ+gLq9-##@HuZPN0]u:h7.T..G:;$/Usj(T7`Q8tT72LnYl<-qx8;-HV7Q-&Xdx%1a,hC=0u+HlsV>nuIQL-5<N?)NBS)QN*_I,?&)2'IM%L3I)X((e/dl2&8'<M"
11637 ":^#M*Q+[T.Xri.LYS3v%fF`68h;b-X[/En'CR.q7E)p'/kle2HM,u;^%OKC-N+Ll%F9CF<Nf'^#t2L,;27W:0O@6##U6W7:$rJfLWHj$#)woqBefIZ.PK<b*t7ed;p*_m;4ExK#h@&]>"
11638 "_>@kXQtMacfD.m-VAb8;IReM3$wf0''hra*so568'Ip&vRs849'MRYSp%:t:h5qSgwpEr$B>Q,;s(C#$)`svQuF$##-D,##,g68@2[T;.XSdN9Qe)rpt._K-#5wF)sP'##p#C0c%-Gb%"
11639 "hd+<-j'Ai*x&&HMkT]C'OSl##5RG[JXaHN;d'uA#x._U;.`PU@(Z3dt4r152@:v,'R.Sj'w#0<-;kPI)FfJ&#AYJ&#//)>-k=m=*XnK$>=)72L]0I%>.G690a:$##<,);?;72#?x9+d;"
11640 "^V'9;jY@;)br#q^YQpx:X#Te$Z^'=-=bGhLf:D6&bNwZ9-ZD#n^9HhLMr5G;']d&6'wYmTFmL<LD)F^%[tC'8;+9E#C$g%#5Y>q9wI>P(9mI[>kC-ekLC/R&CH+s'B;K-M6$EB%is00:"
11641 "+A4[7xks.LrNk0&E)wILYF@2L'0Nb$+pv<(2.768/FrY&h$^3i&@+G%JT'<-,v`3;_)I9M^AE]CN?Cl2AZg+%4iTpT3<n-&%H%b<FDj2M<hH=&Eh<2Len$b*aTX=-8QxN)k11IM1c^j%"
11642 "9s<L<NFSo)B?+<-(GxsF,^-Eh@$4dXhN$+#rxK8'je'D7k`e;)2pYwPA'_p9&@^18ml1^[@g4t*[JOa*[=Qp7(qJ_oOL^('7fB&Hq-:sf,sNj8xq^>$U4O]GKx'm9)b@p7YsvK3w^YR-"
11643 "CdQ*:Ir<($u&)#(&?L9Rg3H)4fiEp^iI9O8KnTj,]H?D*r7'M;PwZ9K0E^k&-cpI;.p/6_vwoFMV<->#%Xi.LxVnrU(4&8/P+:hLSKj$#U%]49t'I:rgMi'FL@a:0Y-uA[39',(vbma*"
11644 "hU%<-SRF`Tt:542R_VV$p@[p8DV[A,?1839FWdF<TddF<9Ah-6&9tWoDlh]&1SpGMq>Ti1O*H&#(AL8[_P%.M>v^-))qOT*F5Cq0`Ye%+$B6i:7@0IX<N+T+0MlMBPQ*Vj>SsD<U4JHY"
11645 "8kD2)2fU/M#$e.)T4,_=8hLim[&);?UkK'-x?'(:siIfL<$pFM`i<?%W(mGDHM%>iWP,##P`%/L<eXi:@Z9C.7o=@(pXdAO/NLQ8lPl+HPOQa8wD8=^GlPa8TKI1CjhsCTSLJM'/Wl>-"
11646 "S(qw%sf/@%#B6;/U7K]uZbi^Oc^2n<bhPmUkMw>%t<)'mEVE''n`WnJra$^TKvX5B>;_aSEK',(hwa0:i4G?.Bci.(X[?b*($,=-n<.Q%`(X=?+@Am*Js0&=3bh8K]mL<LoNs'6,'85`"
11647 "0?t/'_U59@]ddF<#LdF<eWdF<OuN/45rY<-L@&#+fm>69=Lb,OcZV/);TTm8VI;?%OtJ<(b4mq7M6:u?KRdF<gR@2L=FNU-<b[(9c/ML3m;Z[$oF3g)GAWqpARc=<ROu7cL5l;-[A]%/"
11648 "+fsd;l#SafT/f*W]0=O'$(Tb<[)*@e775R-:Yob%g*>l*:xP?Yb.5)%w_I?7uk5JC+FS(m#i'k.'a0i)9<7b'fs'59hq$*5Uhv##pi^8+hIEBF`nvo`;'l0.^S1<-wUK2/Coh58KKhLj"
11649 "M=SO*rfO`+qC`W-On.=AJ56>>i2@2LH6A:&5q`?9I3@@'04&p2/LVa*T-4<-i3;M9UvZd+N7>b*eIwg:CC)c<>nO&#<IGe;__.thjZl<%w(Wk2xmp4Q@I#I9,DF]u7-P=.-_:YJ]aS@V"
11650 "?6*C()dOp7:WL,b&3Rg/.cmM9&r^>$(>.Z-I&J(Q0Hd5Q%7Co-b`-c<N(6r@ip+AurK<m86QIth*#v;-OBqi+L7wDE-Ir8K['m+DDSLwK&/.?-V%U_%3:qKNu$_b*B-kp7NaD'QdWQPK"
11651 "Yq[@>P)hI;*_F]u`Rb[.j8_Q/<&>uu+VsH$sM9TA%?)(vmJ80),P7E>)tjD%2L=-t#fK[%`v=Q8<FfNkgg^oIbah*#8/Qt$F&:K*-(N/'+1vMB,u()-a.VUU*#[e%gAAO(S>WlA2);Sa"
11652 ">gXm8YB`1d@K#n]76-a$U,mF<fX]idqd)<3,]J7JmW4`6]uks=4-72L(jEk+:bJ0M^q-8Dm_Z?0olP1C9Sa&H[d&c$ooQUj]Exd*3ZM@-WGW2%s',B-_M%>%Ul:#/'xoFM9QX-$.QN'>"
11653 "[%$Z$uF6pA6Ki2O5:8w*vP1<-1`[G,)-m#>0`P&#eb#.3i)rtB61(o'$?X3B</R90;eZ]%Ncq;-Tl]#F>2Qft^ae_5tKL9MUe9b*sLEQ95C&`=G?@Mj=wh*'3E>=-<)Gt*Iw)'QG:`@I"
11654 "wOf7&]1i'S01B+Ev/Nac#9S;=;YQpg_6U`*kVY39xK,[/6Aj7:'1Bm-_1EYfa1+o&o4hp7KN_Q(OlIo@S%;jVdn0'1<Vc52=u`3^o-n1'g4v58Hj&6_t7$##?M)c<$bgQ_'SY((-xkA#"
11655 "Y(,p'H9rIVY-b,'%bCPF7.J<Up^,(dU1VY*5#WkTU>h19w,WQhLI)3S#f$2(eb,jr*b;3Vw]*7NH%$c4Vs,eD9>XW8?N]o+(*pgC%/72LV-u<Hp,3@e^9UB1J+ak9-TN/mhKPg+AJYd$"
11656 "MlvAF_jCK*.O-^(63adMT->W%iewS8W6m2rtCpo'RS1R84=@paTKt)>=%&1[)*vp'u+x,VrwN;&]kuO9JDbg=pO$J*.jVe;u'm0dr9l,<*wMK*Oe=g8lV_KEBFkO'oU]^=[-792#ok,)"
11657 "i]lR8qQ2oA8wcRCZ^7w/Njh;?.stX?Q1>S1q4Bn$)K1<-rGdO'$Wr.Lc.CG)$/*JL4tNR/,SVO3,aUw'DJN:)Ss;wGn9A32ijw%FL+Z0Fn.U9;reSq)bmI32U==5ALuG&#Vf1398/pVo"
11658 "1*c-(aY168o<`JsSbk-,1N;$>0:OUas(3:8Z972LSfF8eb=c-;>SPw7.6hn3m`9^Xkn(r.qS[0;T%&Qc=+STRxX'q1BNk3&*eu2;&8q$&x>Q#Q7^Tf+6<(d%ZVmj2bDi%.3L2n+4W'$P"
11659 "iDDG)g,r%+?,$@?uou5tSe2aN_AQU*<h`e-GI7)?OK2A.d7_c)?wQ5AS@DL3r#7fSkgl6-++D:'A,uq7SvlB$pcpH'q3n0#_%dY#xCpr-l<F0NR@-##FEV6NTF6##$l84N1w?AO>'IAO"
11660 "URQ##V^Fv-XFbGM7Fl(N<3DhLGF%q.1rC$#:T__&Pi68%0xi_&[qFJ(77j_&JWoF.V735&T,[R*:xFR*K5>>#`bW-?4Ne_&6Ne_&6Ne_&n`kr-#GJcM6X;uM6X;uM(.a..^2TkL%oR(#"
11661 ";u.T%fAr%4tJ8&><1=GHZ_+m9/#H1F^R#SC#*N=BA9(D?v[UiFY>>^8p,KKF.W]L29uLkLlu/+4T<XoIB&hx=T1PcDaB&;HH+-AFr?(m9HZV)FKS8JCw;SD=6[^/DZUL`EUDf]GGlG&>"
11662 "w$)F./^n3+rlo+DB;5sIYGNk+i1t-69Jg--0pao7Sm#K)pdHW&;LuDNH@H>#/X-TI(;P>#,Gc>#0Su>#4`1?#8lC?#<xU?#@.i?#D:%@#HF7@#LRI@#P_[@#Tkn@#Xw*A#]-=A#a9OA#"
11663 "d<F&#*;G##.GY##2Sl##6`($#:l:$#>xL$#B.`$#F:r$#JF.%#NR@%#R_R%#Vke%#Zww%#_-4^Rh%Sflr-k'MS.o?.5/sWel/wpEM0%3'/1)K^f1-d>G21&v(35>V`39V7A4=onx4"
11664 "A1OY5EI0;6Ibgr6M$HS7Q<)58C5w,;WoA*#[%T*#`1g*#d=#+#hI5+#lUG+#pbY+#tnl+#x$),#&1;,#*=M,#.I`,#2Ur,#6b.-#;w[H#iQtA#m^0B#qjBB#uvTB##-hB#'9$C#+E6C#"
11665 "/QHC#3^ZC#7jmC#;v)D#?,<D#C8ND#GDaD#KPsD#O]/E#g1A5#KA*1#gC17#MGd;#8(02#L-d3#rWM4#Hga1#,<w0#T.j<#O#'2#CYN1#qa^:#_4m3#o@/=#eG8=#t8J5#`+78#4uI-#"
11666 "m3B2#SB[8#Q0@8#i[*9#iOn8#1Nm;#^sN9#qh<9#:=x-#P;K2#$%X9#bC+.#Rg;<#mN=.#MTF.#RZO.#2?)4#Y#(/#[)1/#b;L/#dAU/#0Sv;#lY$0#n`-0#sf60#(F24#wrH0#%/e0#"
11667 "TmD<#%JSMFove:CTBEXI:<eh2g)B,3h2^G3i;#d3jD>)4kMYD4lVu`4m`:&5niUA5@(A5BA1]PBB:xlBCC=2CDLXMCEUtiCf&0g2'tN?PGT4CPGT4CPGT4CPGT4CPGT4CPGT4CPGT4CP"
11668 "GT4CPGT4CPGT4CPGT4CPGT4CPGT4CP-qekC`.9kEg^+F$kwViFJTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5o,^<-28ZI'O?;xp"
11669 "O?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xp;7q-#lLYI:xvD=#";
11672 #define NK_CURSOR_DATA_W 90
11673 #define NK_CURSOR_DATA_H 27
11674 NK_GLOBAL const char nk_custom_cursor_data[NK_CURSOR_DATA_W * NK_CURSOR_DATA_H + 1] =
11676 "..- -XXXXXXX- X - X -XXXXXXX - XXXXXXX"
11677 "..- -X.....X- X.X - X.X -X.....X - X.....X"
11678 "--- -XXX.XXX- X...X - X...X -X....X - X....X"
11679 "X - X.X - X.....X - X.....X -X...X - X...X"
11680 "XX - X.X -X.......X- X.......X -X..X.X - X.X..X"
11681 "X.X - X.X -XXXX.XXXX- XXXX.XXXX -X.X X.X - X.X X.X"
11682 "X..X - X.X - X.X - X.X -XX X.X - X.X XX"
11683 "X...X - X.X - X.X - XX X.X XX - X.X - X.X "
11684 "X....X - X.X - X.X - X.X X.X X.X - X.X - X.X "
11685 "X.....X - X.X - X.X - X..X X.X X..X - X.X - X.X "
11686 "X......X - X.X - X.X - X...XXXXXX.XXXXXX...X - X.X XX-XX X.X "
11687 "X.......X - X.X - X.X -X.....................X- X.X X.X-X.X X.X "
11688 "X........X - X.X - X.X - X...XXXXXX.XXXXXX...X - X.X..X-X..X.X "
11689 "X.........X -XXX.XXX- X.X - X..X X.X X..X - X...X-X...X "
11690 "X..........X-X.....X- X.X - X.X X.X X.X - X....X-X....X "
11691 "X......XXXXX-XXXXXXX- X.X - XX X.X XX - X.....X-X.....X "
11692 "X...X..X --------- X.X - X.X - XXXXXXX-XXXXXXX "
11693 "X..X X..X - -XXXX.XXXX- XXXX.XXXX ------------------------------------"
11694 "X.X X..X - -X.......X- X.......X - XX XX - "
11695 "XX X..X - - X.....X - X.....X - X.X X.X - "
11696 " X..X - X...X - X...X - X..X X..X - "
11697 " XX - X.X - X.X - X...XXXXXXXXXXXXX...X - "
11698 "------------ - X - X -X.....................X- "
11699 " ----------------------------------- X...XXXXXXXXXXXXX...X - "
11706 #pragma clang diagnostic pop
11707 #elif defined(__GNUC__) || defined(__GNUG__)
11708 #pragma GCC diagnostic pop
11712 nk_decompress_length(
unsigned char *input)
11714 return (
unsigned int)((input[8] << 24) + (input[9] << 16) + (input[10] << 8) + input[11]);
11724 nk__match(
unsigned char *data,
unsigned int length)
11727 NK_ASSERT (nk__dout + length <= nk__barrier);
11728 if (nk__dout + length > nk__barrier) { nk__dout += length;
return; }
11729 if (data < nk__barrier4) { nk__dout = nk__barrier+1;
return; }
11730 while (length--) *nk__dout++ = *data++;
11734 nk__lit(
unsigned char *data,
unsigned int length)
11736 NK_ASSERT (nk__dout + length <= nk__barrier);
11737 if (nk__dout + length > nk__barrier) { nk__dout += length;
return; }
11738 if (data < nk__barrier2) { nk__dout = nk__barrier+1;
return; }
11739 NK_MEMCPY(nk__dout, data, length);
11740 nk__dout += length;
11743 #define nk__in2(x) ((i[x] << 8) + i[(x)+1])
11744 #define nk__in3(x) ((i[x] << 16) + nk__in2((x)+1))
11745 #define nk__in4(x) ((i[x] << 24) + nk__in3((x)+1))
11748 nk_decompress_token(
unsigned char *i)
11751 if (*i >= 0x80) nk__match(nk__dout-i[1]-1, (
unsigned int)i[0] - 0x80 + 1), i += 2;
11752 else if (*i >= 0x40) nk__match(nk__dout-(nk__in2(0) - 0x4000 + 1), (
unsigned int)i[2]+1), i += 3;
11753 else nk__lit(i+1, (
unsigned int)i[0] - 0x20 + 1), i += 1 + (i[0] - 0x20 + 1);
11755 if (*i >= 0x18) nk__match(nk__dout-(
unsigned int)(nk__in3(0) - 0x180000 + 1), (
unsigned int)i[3]+1), i += 4;
11756 else if (*i >= 0x10) nk__match(nk__dout-(
unsigned int)(nk__in3(0) - 0x100000 + 1), (
unsigned int)nk__in2(3)+1), i += 5;
11757 else if (*i >= 0x08) nk__lit(i+2, (
unsigned int)nk__in2(0) - 0x0800 + 1), i += 2 + (nk__in2(0) - 0x0800 + 1);
11758 else if (*i == 0x07) nk__lit(i+3, (
unsigned int)nk__in2(1) + 1), i += 3 + (nk__in2(1) + 1);
11759 else if (*i == 0x06) nk__match(nk__dout-(
unsigned int)(nk__in3(1)+1), i[4]+1u), i += 5;
11760 else if (*i == 0x04) nk__match(nk__dout-(
unsigned int)(nk__in3(1)+1), (
unsigned int)nk__in2(4)+1u), i += 6;
11766 nk_adler32(
unsigned int adler32,
unsigned char *buffer,
unsigned int buflen)
11768 const unsigned long ADLER_MOD = 65521;
11769 unsigned long s1 = adler32 & 0xffff, s2 = adler32 >> 16;
11770 unsigned long blocklen, i;
11772 blocklen = buflen % 5552;
11774 for (i=0; i + 7 < blocklen; i += 8) {
11775 s1 += buffer[0]; s2 += s1;
11776 s1 += buffer[1]; s2 += s1;
11777 s1 += buffer[2]; s2 += s1;
11778 s1 += buffer[3]; s2 += s1;
11779 s1 += buffer[4]; s2 += s1;
11780 s1 += buffer[5]; s2 += s1;
11781 s1 += buffer[6]; s2 += s1;
11782 s1 += buffer[7]; s2 += s1;
11785 for (; i < blocklen; ++i) {
11786 s1 += *buffer++; s2 += s1;
11789 s1 %= ADLER_MOD; s2 %= ADLER_MOD;
11790 buflen -= (
unsigned int)blocklen;
11793 return (
unsigned int)(s2 << 16) + (
unsigned int)s1;
11797 nk_decompress(
unsigned char *output,
unsigned char *i,
unsigned int length)
11800 if (nk__in4(0) != 0x57bC0000)
return 0;
11801 if (nk__in4(4) != 0)
return 0;
11802 olen = nk_decompress_length(i);
11804 nk__barrier3 = i+length;
11805 nk__barrier = output + olen;
11811 unsigned char *old_i = i;
11812 i = nk_decompress_token(i);
11814 if (*i == 0x05 && i[1] == 0xfa) {
11815 NK_ASSERT(nk__dout == output + olen);
11816 if (nk__dout != output + olen)
return 0;
11817 if (nk_adler32(1, output, olen) != (
unsigned int) nk__in4(2))
11825 NK_ASSERT(nk__dout <= output + olen);
11826 if (nk__dout > output + olen)
11832 nk_decode_85_byte(
char c)
11833 {
return (
unsigned int)((c >=
'\\') ? c-36 : c-35); }
11836 nk_decode_85(
unsigned char* dst,
const unsigned char* src)
11841 nk_decode_85_byte((
char)src[0]) +
11842 85 * (nk_decode_85_byte((
char)src[1]) +
11843 85 * (nk_decode_85_byte((
char)src[2]) +
11844 85 * (nk_decode_85_byte((
char)src[3]) +
11845 85 * nk_decode_85_byte((
char)src[4]))));
11848 dst[0] = (
unsigned char)((tmp >> 0) & 0xFF);
11849 dst[1] = (
unsigned char)((tmp >> 8) & 0xFF);
11850 dst[2] = (
unsigned char)((tmp >> 16) & 0xFF);
11851 dst[3] = (
unsigned char)((tmp >> 24) & 0xFF);
11863 NK_API struct nk_font_config
11864 nk_font_config(float pixel_height)
11866 struct nk_font_config cfg;
11870 cfg.ttf_data_owned_by_atlas = 0;
11871 cfg.size = pixel_height;
11872 cfg.oversample_h = 3;
11873 cfg.oversample_v = 1;
11874 cfg.pixel_snap = 0;
11875 cfg.coord_type = NK_COORD_UV;
11877 cfg.range = nk_font_default_glyph_ranges();
11878 cfg.merge_mode = 0;
11879 cfg.fallback_glyph =
'?';
11884 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
11886 nk_font_atlas_init_default(
struct nk_font_atlas *atlas)
11889 if (!atlas)
return;
11891 atlas->temporary.userdata.ptr = 0;
11892 atlas->temporary.alloc = nk_malloc;
11893 atlas->temporary.free = nk_mfree;
11894 atlas->permanent.userdata.ptr = 0;
11895 atlas->permanent.alloc = nk_malloc;
11896 atlas->permanent.free = nk_mfree;
11901 nk_font_atlas_init(
struct nk_font_atlas *atlas,
struct nk_allocator *alloc)
11905 if (!atlas || !alloc)
return;
11907 atlas->permanent = *alloc;
11908 atlas->temporary = *alloc;
11912 nk_font_atlas_init_custom(
struct nk_font_atlas *atlas,
11916 NK_ASSERT(permanent);
11917 NK_ASSERT(temporary);
11918 if (!atlas || !permanent || !temporary)
return;
11920 atlas->permanent = *permanent;
11921 atlas->temporary = *temporary;
11925 nk_font_atlas_begin(
struct nk_font_atlas *atlas)
11928 NK_ASSERT(atlas->temporary.alloc && atlas->temporary.free);
11929 NK_ASSERT(atlas->permanent.alloc && atlas->permanent.free);
11930 if (!atlas || !atlas->permanent.alloc || !atlas->permanent.free ||
11931 !atlas->temporary.alloc || !atlas->temporary.free)
return;
11932 if (atlas->glyphs) {
11933 atlas->permanent.free(atlas->permanent.userdata, atlas->glyphs);
11936 if (atlas->pixel) {
11937 atlas->permanent.free(atlas->permanent.userdata, atlas->pixel);
11943 nk_font_atlas_add(
struct nk_font_atlas *atlas,
const struct nk_font_config *config)
11945 struct nk_font *font = 0;
11946 struct nk_font_config *cfg;
11949 NK_ASSERT(atlas->permanent.alloc);
11950 NK_ASSERT(atlas->permanent.free);
11951 NK_ASSERT(atlas->temporary.alloc);
11952 NK_ASSERT(atlas->temporary.free);
11955 NK_ASSERT(config->ttf_blob);
11956 NK_ASSERT(config->ttf_size);
11957 NK_ASSERT(config->size > 0.0f);
11959 if (!atlas || !config || !config->ttf_blob || !config->ttf_size || config->size <= 0.0f||
11960 !atlas->permanent.alloc || !atlas->permanent.free ||
11961 !atlas->temporary.alloc || !atlas->temporary.free)
11965 cfg = (
struct nk_font_config*)
11966 atlas->permanent.alloc(atlas->permanent.userdata,0,
sizeof(
struct nk_font_config));
11967 NK_MEMCPY(cfg, config,
sizeof(*config));
11968 if (!atlas->config) {
11969 atlas->config = cfg;
11972 cfg->next = atlas->config;
11973 atlas->config = cfg;
11977 if (!config->merge_mode) {
11978 font = (
struct nk_font*)
11979 atlas->permanent.alloc(atlas->permanent.userdata,0,
sizeof(
struct nk_font));
11981 if (!font)
return 0;
11982 font->config = cfg;
11984 NK_ASSERT(atlas->font_num);
11985 font = atlas->fonts;
11986 font->config = cfg;
11990 if (!config->merge_mode) {
11991 if (!atlas->fonts) {
11992 atlas->fonts = font;
11995 font->next = atlas->fonts;
11996 atlas->fonts = font;
11998 cfg->font = &font->info;
12002 if (!config->ttf_data_owned_by_atlas) {
12003 cfg->ttf_blob = atlas->permanent.alloc(atlas->permanent.userdata,0, cfg->ttf_size);
12004 NK_ASSERT(cfg->ttf_blob);
12005 if (!cfg->ttf_blob) {
12009 NK_MEMCPY(cfg->ttf_blob, config->ttf_blob, cfg->ttf_size);
12010 cfg->ttf_data_owned_by_atlas = 1;
12017 nk_font_atlas_add_from_memory(
struct nk_font_atlas *atlas,
void *memory,
12018 nk_size size,
float height,
const struct nk_font_config *config)
12020 struct nk_font_config cfg;
12025 NK_ASSERT(atlas->temporary.alloc);
12026 NK_ASSERT(atlas->temporary.free);
12027 NK_ASSERT(atlas->permanent.alloc);
12028 NK_ASSERT(atlas->permanent.free);
12029 if (!atlas || !atlas->temporary.alloc || !atlas->temporary.free || !memory || !size ||
12030 !atlas->permanent.alloc || !atlas->permanent.free)
12033 cfg = (
config) ? *config: nk_font_config(height);
12034 cfg.ttf_blob = memory;
12035 cfg.ttf_size = size;
12037 cfg.ttf_data_owned_by_atlas = 0;
12038 return nk_font_atlas_add(atlas, &cfg);
12041 #ifdef NK_INCLUDE_STANDARD_IO
12043 nk_font_atlas_add_from_file(
struct nk_font_atlas *atlas,
const char *file_path,
12044 float height,
const struct nk_font_config *config)
12048 struct nk_font_config cfg;
12051 NK_ASSERT(atlas->temporary.alloc);
12052 NK_ASSERT(atlas->temporary.free);
12053 NK_ASSERT(atlas->permanent.alloc);
12054 NK_ASSERT(atlas->permanent.free);
12056 if (!atlas || !file_path)
return 0;
12057 memory = nk_file_load(file_path, &size, &atlas->permanent);
12058 if (!memory)
return 0;
12060 cfg = (
config) ? *config: nk_font_config(height);
12061 cfg.ttf_blob = memory;
12062 cfg.ttf_size = size;
12064 cfg.ttf_data_owned_by_atlas = 1;
12065 return nk_font_atlas_add(atlas, &cfg);
12070 nk_font_atlas_add_compressed(
struct nk_font_atlas *atlas,
12071 void *compressed_data, nk_size compressed_size,
float height,
12072 const struct nk_font_config *config)
12074 unsigned int decompressed_size;
12075 void *decompressed_data;
12076 struct nk_font_config cfg;
12079 NK_ASSERT(atlas->temporary.alloc);
12080 NK_ASSERT(atlas->temporary.free);
12081 NK_ASSERT(atlas->permanent.alloc);
12082 NK_ASSERT(atlas->permanent.free);
12084 NK_ASSERT(compressed_data);
12085 NK_ASSERT(compressed_size);
12086 if (!atlas || !compressed_data || !atlas->temporary.alloc || !atlas->temporary.free ||
12087 !atlas->permanent.alloc || !atlas->permanent.free)
12090 decompressed_size = nk_decompress_length((
unsigned char*)compressed_data);
12091 decompressed_data = atlas->permanent.alloc(atlas->permanent.userdata,0,decompressed_size);
12092 NK_ASSERT(decompressed_data);
12093 if (!decompressed_data)
return 0;
12094 nk_decompress((
unsigned char*)decompressed_data, (
unsigned char*)compressed_data,
12095 (
unsigned int)compressed_size);
12097 cfg = (
config) ? *config: nk_font_config(height);
12098 cfg.ttf_blob = decompressed_data;
12099 cfg.ttf_size = decompressed_size;
12101 cfg.ttf_data_owned_by_atlas = 1;
12102 return nk_font_atlas_add(atlas, &cfg);
12106 nk_font_atlas_add_compressed_base85(
struct nk_font_atlas *atlas,
12107 const char *data_base85,
float height,
const struct nk_font_config *config)
12109 int compressed_size;
12110 void *compressed_data;
12111 struct nk_font *font;
12114 NK_ASSERT(atlas->temporary.alloc);
12115 NK_ASSERT(atlas->temporary.free);
12116 NK_ASSERT(atlas->permanent.alloc);
12117 NK_ASSERT(atlas->permanent.free);
12119 NK_ASSERT(data_base85);
12120 if (!atlas || !data_base85 || !atlas->temporary.alloc || !atlas->temporary.free ||
12121 !atlas->permanent.alloc || !atlas->permanent.free)
12124 compressed_size = (((
int)
nk_strlen(data_base85) + 4) / 5) * 4;
12125 compressed_data = atlas->temporary.alloc(atlas->temporary.userdata,0, (nk_size)compressed_size);
12126 NK_ASSERT(compressed_data);
12127 if (!compressed_data)
return 0;
12128 nk_decode_85((
unsigned char*)compressed_data, (
const unsigned char*)data_base85);
12129 font = nk_font_atlas_add_compressed(atlas, compressed_data,
12130 (nk_size)compressed_size, height, config);
12131 atlas->temporary.free(atlas->temporary.userdata, compressed_data);
12135 #ifdef NK_INCLUDE_DEFAULT_FONT
12137 nk_font_atlas_add_default(
struct nk_font_atlas *atlas,
12138 float pixel_height,
const struct nk_font_config *config)
12141 NK_ASSERT(atlas->temporary.alloc);
12142 NK_ASSERT(atlas->temporary.free);
12143 NK_ASSERT(atlas->permanent.alloc);
12144 NK_ASSERT(atlas->permanent.free);
12145 return nk_font_atlas_add_compressed_base85(atlas,
12146 nk_proggy_clean_ttf_compressed_data_base85, pixel_height, config);
12151 nk_font_atlas_bake(
struct nk_font_atlas *atlas,
int *width,
int *height,
12152 enum nk_font_atlas_format fmt)
12156 nk_size tmp_size, img_size;
12157 struct nk_font *font_iter;
12158 struct nk_font_baker *baker;
12161 NK_ASSERT(atlas->temporary.alloc);
12162 NK_ASSERT(atlas->temporary.free);
12163 NK_ASSERT(atlas->permanent.alloc);
12164 NK_ASSERT(atlas->permanent.free);
12168 if (!atlas || !width || !height ||
12169 !atlas->temporary.alloc || !atlas->temporary.free ||
12170 !atlas->permanent.alloc || !atlas->permanent.free)
12173 #ifdef NK_INCLUDE_DEFAULT_FONT
12175 if (!atlas->font_num)
12176 atlas->default_font = nk_font_atlas_add_default(atlas, 13.0f, 0);
12178 NK_ASSERT(atlas->font_num);
12179 if (!atlas->font_num)
return 0;
12182 nk_font_baker_memory(&tmp_size, &atlas->glyph_count, atlas->config, atlas->font_num);
12183 tmp = atlas->temporary.alloc(atlas->temporary.userdata,0, tmp_size);
12185 if (!tmp)
goto failed;
12188 baker = nk_font_baker(tmp, atlas->glyph_count, atlas->font_num, &atlas->temporary);
12189 atlas->glyphs = (
struct nk_font_glyph*)atlas->permanent.alloc(
12190 atlas->permanent.userdata,0,
sizeof(
struct nk_font_glyph)*(nk_size)atlas->glyph_count);
12191 NK_ASSERT(atlas->glyphs);
12192 if (!atlas->glyphs)
12196 atlas->custom.w = (NK_CURSOR_DATA_W*2)+1;
12197 atlas->custom.h = NK_CURSOR_DATA_H + 1;
12198 if (!nk_font_bake_pack(baker, &img_size, width, height, &atlas->custom,
12199 atlas->config, atlas->font_num, &atlas->temporary))
12203 atlas->pixel = atlas->temporary.alloc(atlas->temporary.userdata,0, img_size);
12204 NK_ASSERT(atlas->pixel);
12209 nk_font_bake(baker, atlas->pixel, *width, *height,
12210 atlas->glyphs, atlas->glyph_count, atlas->config, atlas->font_num);
12211 nk_font_bake_custom_data(atlas->pixel, *width, *height, atlas->custom,
12212 nk_custom_cursor_data, NK_CURSOR_DATA_W, NK_CURSOR_DATA_H,
'.',
'X');
12214 if (fmt == NK_FONT_ATLAS_RGBA32) {
12216 void *img_rgba = atlas->temporary.alloc(atlas->temporary.userdata,0,
12217 (nk_size)(*width * *height * 4));
12218 NK_ASSERT(img_rgba);
12219 if (!img_rgba)
goto failed;
12220 nk_font_bake_convert(img_rgba, *width, *height, atlas->pixel);
12221 atlas->temporary.free(atlas->temporary.userdata, atlas->pixel);
12222 atlas->pixel = img_rgba;
12224 atlas->tex_width = *width;
12225 atlas->tex_height = *height;
12228 for (font_iter = atlas->fonts; font_iter; font_iter = font_iter->next) {
12229 struct nk_font *font = font_iter;
12230 struct nk_font_config *config = font->config;
12231 nk_font_init(font, config->size, config->fallback_glyph, atlas->glyphs,
12238 {{ 0, 3}, {12,19}, { 0, 0}},
12239 {{13, 0}, { 7,16}, { 4, 8}},
12240 {{31, 0}, {23,23}, {11,11}},
12241 {{21, 0}, { 9, 23}, { 5,11}},
12242 {{55,18}, {23, 9}, {11, 5}},
12243 {{73, 0}, {17,17}, { 9, 9}},
12244 {{55, 0}, {17,17}, { 9, 9}}
12247 struct nk_cursor *cursor = &atlas->cursors[i];
12248 cursor->
img.
w = (
unsigned short)*width;
12249 cursor->
img.
h = (
unsigned short)*height;
12250 cursor->
img.
region[0] = (
unsigned short)(atlas->custom.x + nk_cursor_data[i][0].
x);
12251 cursor->
img.
region[1] = (
unsigned short)(atlas->custom.y + nk_cursor_data[i][0].
y);
12252 cursor->
img.
region[2] = (
unsigned short)nk_cursor_data[i][1].x;
12253 cursor->
img.
region[3] = (
unsigned short)nk_cursor_data[i][1].y;
12254 cursor->size = nk_cursor_data[i][1];
12255 cursor->
offset = nk_cursor_data[i][2];
12258 atlas->temporary.free(atlas->temporary.userdata, tmp);
12259 return atlas->pixel;
12263 if (tmp) atlas->temporary.free(atlas->temporary.userdata, tmp);
12264 if (atlas->glyphs) {
12265 atlas->permanent.free(atlas->permanent.userdata, atlas->glyphs);
12268 if (atlas->pixel) {
12269 atlas->temporary.free(atlas->temporary.userdata, atlas->pixel);
12276 nk_font_atlas_end(
struct nk_font_atlas *atlas, nk_handle texture,
12280 struct nk_font *font_iter;
12289 null->
uv.
x = (atlas->custom.x + 0.5f)/(
float)atlas->tex_width;
12290 null->
uv.
y = (atlas->custom.y + 0.5f)/(
float)atlas->tex_height;
12292 for (font_iter = atlas->fonts; font_iter; font_iter = font_iter->next) {
12293 font_iter->texture =
texture;
12294 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
12295 font_iter->handle.texture =
texture;
12299 atlas->cursors[i].img.handle = texture;
12301 atlas->temporary.free(atlas->temporary.userdata, atlas->pixel);
12303 atlas->tex_width = 0;
12304 atlas->tex_height = 0;
12305 atlas->custom.x = 0;
12306 atlas->custom.y = 0;
12307 atlas->custom.w = 0;
12308 atlas->custom.h = 0;
12312 nk_font_atlas_cleanup(
struct nk_font_atlas *atlas)
12315 NK_ASSERT(atlas->temporary.alloc);
12316 NK_ASSERT(atlas->temporary.free);
12317 NK_ASSERT(atlas->permanent.alloc);
12318 NK_ASSERT(atlas->permanent.free);
12320 if (!atlas || !atlas->permanent.alloc || !atlas->permanent.free)
return;
12321 if (atlas->config) {
12322 struct nk_font_config *iter, *next;
12323 for (iter = atlas->config; iter; iter = next) {
12325 atlas->permanent.free(atlas->permanent.userdata, iter->ttf_blob);
12326 atlas->permanent.free(atlas->permanent.userdata, iter);
12332 nk_font_atlas_clear(
struct nk_font_atlas *atlas)
12335 NK_ASSERT(atlas->temporary.alloc);
12336 NK_ASSERT(atlas->temporary.free);
12337 NK_ASSERT(atlas->permanent.alloc);
12338 NK_ASSERT(atlas->permanent.free);
12339 if (!atlas || !atlas->permanent.alloc || !atlas->permanent.free)
return;
12341 nk_font_atlas_cleanup(atlas);
12342 if (atlas->fonts) {
12343 struct nk_font *iter, *next;
12344 for (iter = atlas->fonts; iter; iter = next) {
12346 atlas->permanent.free(atlas->permanent.userdata, iter);
12351 atlas->permanent.free(atlas->permanent.userdata, atlas->glyphs);
12636 struct nk_text_find {
12639 int first_char, length;
12643 struct nk_text_edit_row {
12646 float baseline_y_delta;
12657 #define NK_TEXT_HAS_SELECTION(s) ((s)->select_start != (s)->select_end)
12660 nk_textedit_get_width(
const struct nk_text_edit *edit,
int line_start,
int char_id,
12664 nk_rune unicode = 0;
12670 nk_textedit_layout_row(
struct nk_text_edit_row *r,
struct nk_text_edit *edit,
12671 int line_start_id,
float row_height,
const struct nk_user_font *font)
12676 const char *remaining;
12680 const struct nk_vec2 size = nk_text_calculate_text_bounds(font,
12681 text, (
int)(end - text), row_height, &remaining, 0, &glyphs, NK_STOP_ON_NEW_LINE);
12685 r->baseline_y_delta = size.
y;
12688 r->num_chars = glyphs;
12692 nk_textedit_locate_coord(
struct nk_text_edit *edit,
float x,
float y,
12695 struct nk_text_edit_row r;
12697 float base_y = 0, prev_x;
12701 r.ymin = r.ymax = 0;
12706 nk_textedit_layout_row(&r, edit, i, row_height, font);
12707 if (r.num_chars <= 0)
12710 if (i==0 && y < base_y + r.ymin)
12713 if (y < base_y + r.ymax)
12717 base_y += r.baseline_y_delta;
12733 for (i=0; i < r.num_chars; ++i) {
12734 float w = nk_textedit_get_width(edit, k, i, font);
12735 if (x < prev_x+w) {
12736 if (x < prev_x+w/2)
12748 return i+r.num_chars-1;
12749 else return i+r.num_chars;
12753 nk_textedit_click(
struct nk_text_edit *state,
float x,
float y,
12758 state->
cursor = nk_textedit_locate_coord(state, x, y, font, row_height);
12765 nk_textedit_drag(
struct nk_text_edit *state,
float x,
float y,
12770 int p = nk_textedit_locate_coord(state, x, y, font, row_height);
12777 nk_textedit_find_charpos(
struct nk_text_find *find,
struct nk_text_edit *state,
12778 int n,
int single_line,
const struct nk_user_font *font,
float row_height)
12782 struct nk_text_edit_row r;
12783 int prev_start = 0;
12791 nk_textedit_layout_row(&r, state, 0, row_height, font);
12793 find->first_char = 0;
12799 nk_textedit_layout_row(&r, state, i, row_height, font);
12802 find->first_char = i;
12803 find->length = r.num_chars;
12807 find->height = r.ymax - r.ymin;
12808 find->prev_first = prev_start;
12816 nk_textedit_layout_row(&r, state, i, row_height, font);
12817 if (n < i + r.num_chars)
break;
12820 find->y += r.baseline_y_delta;
12823 find->first_char = first = i;
12824 find->length = r.num_chars;
12825 find->height = r.ymax - r.ymin;
12826 find->prev_first = prev_start;
12830 for (i=0; first+i < n; ++i)
12831 find->x += nk_textedit_get_width(state, first, i, font);
12839 if (NK_TEXT_HAS_SELECTION(state)) {
12853 nk_textedit_makeundo_delete(state, where, len);
12862 nk_textedit_clamp(state);
12863 if (NK_TEXT_HAS_SELECTION(state)) {
12892 if (NK_TEXT_HAS_SELECTION(state)) {
12893 nk_textedit_sortselection(state);
12904 if (NK_TEXT_HAS_SELECTION(state)) {
12905 nk_textedit_sortselection(state);
12906 nk_textedit_clamp(state);
12914 nk_is_word_boundary(
struct nk_text_edit *state,
int idx)
12918 if (idx <= 0)
return 1;
12920 return (c ==
' ' || c ==
'\t' ||c == 0x3000 || c ==
',' || c ==
';' ||
12921 c ==
'(' || c ==
')' || c ==
'{' || c ==
'}' || c ==
'[' || c ==
']' ||
12926 nk_textedit_move_to_word_previous(
struct nk_text_edit *state)
12928 int c = state->
cursor - 1;
12929 while( c >= 0 && !nk_is_word_boundary(state, c))
12939 nk_textedit_move_to_word_next(
struct nk_text_edit *state)
12942 int c = state->
cursor+1;
12943 while( c < len && !nk_is_word_boundary(state, c))
12953 nk_textedit_prep_selection_at_cursor(
struct nk_text_edit *state)
12956 if (!NK_TEXT_HAS_SELECTION(state))
12967 if (NK_TEXT_HAS_SELECTION(state)) {
12980 const char *text = (
const char *) ctext;
12984 nk_textedit_clamp(state);
12990 nk_textedit_makeundo_insert(state, state->
cursor, glyphs);
13013 while ((text_len < total_len) && glyph_len)
13016 if (unicode == 127)
goto next;
13018 if (unicode ==
'\n' && state->
single_line)
goto next;
13020 if (state->
filter && !state->
filter(state, unicode))
goto next;
13022 if (!NK_TEXT_HAS_SELECTION(state) &&
13026 nk_textedit_makeundo_replace(state, state->
cursor, 1, 1);
13040 nk_textedit_makeundo_insert(state, state->
cursor, 1);
13046 text_len += glyph_len;
13047 glyph_len =
nk_utf_decode(text + text_len, &unicode, total_len-text_len);
13099 nk_textedit_clamp(state);
13100 nk_textedit_prep_selection_at_cursor(state);
13109 if (NK_TEXT_HAS_SELECTION(state))
13110 nk_textedit_move_to_first(state);
13111 else if (state->
cursor > 0)
13118 nk_textedit_prep_selection_at_cursor(state);
13121 nk_textedit_clamp(state);
13127 if (NK_TEXT_HAS_SELECTION(state))
13128 nk_textedit_move_to_last(state);
13130 nk_textedit_clamp(state);
13136 if( !NK_TEXT_HAS_SELECTION( state ) )
13137 nk_textedit_prep_selection_at_cursor(state);
13138 state->
cursor = nk_textedit_move_to_word_previous(state);
13140 nk_textedit_clamp(state );
13142 if (NK_TEXT_HAS_SELECTION(state))
13143 nk_textedit_move_to_first(state);
13145 state->
cursor = nk_textedit_move_to_word_previous(state);
13146 nk_textedit_clamp(state );
13152 if( !NK_TEXT_HAS_SELECTION( state ) )
13153 nk_textedit_prep_selection_at_cursor(state);
13154 state->
cursor = nk_textedit_move_to_word_next(state);
13156 nk_textedit_clamp(state);
13158 if (NK_TEXT_HAS_SELECTION(state))
13159 nk_textedit_move_to_last(state);
13161 state->
cursor = nk_textedit_move_to_word_next(state);
13162 nk_textedit_clamp(state );
13167 struct nk_text_find find;
13168 struct nk_text_edit_row row;
13169 int i, sel = shift_mod;
13178 nk_textedit_prep_selection_at_cursor(state);
13179 else if (NK_TEXT_HAS_SELECTION(state))
13180 nk_textedit_move_to_last(state);
13183 nk_textedit_clamp(state);
13192 int start = find.first_char + find.length;
13195 nk_textedit_layout_row(&row, state, state->
cursor, row_height, font);
13198 for (i=0; i < row.num_chars && x < row.x1; ++i) {
13199 float dx = nk_textedit_get_width(state, start, i, font);
13205 nk_textedit_clamp(state);
13215 struct nk_text_find find;
13216 struct nk_text_edit_row row;
13217 int i, sel = shift_mod;
13226 nk_textedit_prep_selection_at_cursor(state);
13227 else if (NK_TEXT_HAS_SELECTION(state))
13228 nk_textedit_move_to_first(state);
13231 nk_textedit_clamp(state);
13236 if (find.prev_first != find.first_char) {
13241 state->
cursor = find.prev_first;
13242 nk_textedit_layout_row(&row, state, state->
cursor, row_height, font);
13245 for (i=0; i < row.num_chars && x < row.x1; ++i) {
13246 float dx = nk_textedit_get_width(state, find.prev_first, i, font);
13252 nk_textedit_clamp(state);
13263 if (NK_TEXT_HAS_SELECTION(state))
13276 if (NK_TEXT_HAS_SELECTION(state))
13279 nk_textedit_clamp(state);
13280 if (state->
cursor > 0) {
13290 nk_textedit_prep_selection_at_cursor(state);
13301 nk_textedit_prep_selection_at_cursor(state);
13313 struct nk_text_find find;
13314 nk_textedit_clamp(state);
13315 nk_textedit_prep_selection_at_cursor(state);
13323 struct nk_text_find find;
13326 nk_textedit_clamp(state);
13327 nk_textedit_move_to_first(state);
13330 state->
cursor = find.first_char;
13337 struct nk_text_find find;
13338 nk_textedit_clamp(state);
13339 nk_textedit_prep_selection_at_cursor(state);
13343 state->
cursor = find.first_char + find.length;
13348 struct nk_text_find find;
13349 nk_textedit_clamp(state);
13350 nk_textedit_move_to_first(state);
13355 state->
cursor = find.first_char + find.length;
13429 nk_textedit_flush_redo(state);
13434 nk_textedit_discard_undo(state);
13447 nk_textedit_discard_undo(state);
13453 int insert_len,
int delete_len)
13463 if (insert_len == 0) {
13488 r->
where = u.where;
13490 if (u.delete_length)
13509 nk_textedit_discard_redo(s);
13520 for (i=0; i < u.delete_length; ++i)
13529 if (u.insert_length) {
13532 &s->
undo_char[u.char_storage], u.insert_length);
13535 state->
cursor = (short)(u.where + u.insert_length);
13594 nk_textedit_createundo(&state->
undo, where, 0, length);
13601 nk_rune *p = nk_textedit_createundo(&state->
undo, where, length, 0);
13603 for (i=0; i < length; ++i)
13609 nk_textedit_makeundo_replace(
struct nk_text_edit *state,
int where,
13610 int old_length,
int new_length)
13613 nk_rune *p = nk_textedit_createundo(&state->
undo, where, old_length, new_length);
13615 for (i=0; i < old_length; ++i)
13646 if (!state || !memory || !size)
return;
13656 if (!state || !alloc)
return;
13661 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
13666 if (!state)
return;
13668 nk_str_init_default(&state->
string);
13684 if (!state)
return;
13693 #define nk_widget_state_reset(s)\
13694 if ((*(s)) & NK_WIDGET_STATE_MODIFIED)\
13695 (*(s)) = NK_WIDGET_STATE_INACTIVE|NK_WIDGET_STATE_MODIFIED;\
13696 else (*(s)) = NK_WIDGET_STATE_INACTIVE;
13706 const char *
string,
int len,
const struct nk_text *t,
13714 if (!o || !t)
return;
13716 b.
h =
NK_MAX(b.
h, 2 * t->padding.y);
13717 label.x = 0; label.w = 0;
13718 label.y = b.
y + t->padding.y;
13722 text_width += (2.0f * t->padding.x);
13726 label.x = b.
x + t->padding.x;
13727 label.w =
NK_MAX(0, b.
w - 2 * t->padding.x);
13729 label.w =
NK_MAX(1, 2 * t->padding.x + (
float)text_width);
13730 label.x = (b.
x + t->padding.x + ((b.
w - 2 * t->padding.x) - label.w) / 2);
13731 label.x =
NK_MAX(b.
x + t->padding.x, label.x);
13732 label.w =
NK_MIN(b.
x + b.
w, label.x + label.w);
13733 if (label.w >= label.x) label.w -= label.x;
13735 label.x =
NK_MAX(b.
x + t->padding.x, (b.
x + b.
w) - (2 * t->padding.x + (
float)text_width));
13736 label.w = (float)text_width + 2 * t->padding.x;
13741 label.y = b.
y + b.
h/2.0f - (float)f->
height/2.0f;
13748 len, f, t->background, t->text);
13753 const char *
string,
int len,
const struct nk_text *t,
13766 if (!o || !t)
return;
13769 text.background = t->background;
13770 text.text = t->text;
13772 b.
w =
NK_MAX(b.
w, 2 * t->padding.x);
13773 b.
h =
NK_MAX(b.
h, 2 * t->padding.y);
13774 b.
h = b.
h - 2 * t->padding.y;
13776 line.x = b.
x + t->padding.x;
13777 line.y = b.
y + t->padding.y;
13778 line.w = b.
w - 2 * t->padding.x;
13779 line.h = 2 * t->padding.y + f->
height;
13781 fitting = nk_text_clamp(f,
string, len, line.w, &glyphs, &width, seperator,
NK_LEN(seperator));
13782 while (done < len) {
13783 if (!fitting || line.y + line.h >= (b.
y + b.
h))
break;
13784 nk_widget_text(o, line, &
string[done], fitting, &text,
NK_TEXT_LEFT, f);
13786 line.y += f->
height + 2 * t->padding.y;
13787 fitting = nk_text_clamp(f, &
string[done], len - done, line.w, &glyphs, &width, seperator,
NK_LEN(seperator));
13812 text.background = background;
13813 text.text = foreground;
13824 nk_fill_rect(out, nk_shrink_rect(content, border_width), 0, background);
13842 points[2].x, points[2].y, foreground);
13855 nk_widget_state_reset(state);
13864 #ifdef NK_BUTTON_TRIGGER_ON_RELEASE
13880 const struct nk_rect *bounds, nk_flags state,
13885 background = &style->
hover;
13887 background = &style->
active;
13888 else background = &style->
normal;
13908 if (!out || !style)
13927 const struct nk_rect *bounds,
const struct nk_rect *content, nk_flags state,
13929 nk_flags text_alignment,
const struct nk_user_font *font)
13933 background = nk_draw_button(out, bounds, state, style);
13937 text.background = background->
data.
color;
13939 if (state & NK_WIDGET_STATE_HOVER)
13941 else if (state & NK_WIDGET_STATE_ACTIVED)
13946 nk_widget_text(out, *content, txt, len, &text, text_alignment, font);
13950 nk_do_button_text(nk_flags *state,
13964 if (!out || !style || !font || !
string)
13967 ret = nk_do_button(state, out, bounds, style, in, behavior, &content);
13969 nk_draw_button_text(out, &bounds, &content, *state, style,
string, len, align, font);
13984 background = nk_draw_button(out, bounds, state, style);
13989 if (state & NK_WIDGET_STATE_HOVER)
13991 else if (state & NK_WIDGET_STATE_ACTIVED)
13994 nk_draw_symbol(out, type, *content, bg, sym, 1, font);
13998 nk_do_button_symbol(nk_flags *state,
14011 if (!out || !style || !font || !state)
14014 ret = nk_do_button(state, out, bounds, style, in, behavior, &content);
14016 nk_draw_button_symbol(out, &bounds, &content, *state, style, symbol, font);
14026 nk_draw_button(out, bounds, state, style);
14031 nk_do_button_image(nk_flags *state,
14042 if (!out || !style || !state)
14045 ret = nk_do_button(state, out, bounds, style, in, b, &content);
14052 nk_draw_button_image(out, &bounds, &content, *state, style, &img);
14069 background = nk_draw_button(out, bounds, state, style);
14071 text.background = background->
data.
color;
14075 if (state & NK_WIDGET_STATE_HOVER) {
14078 }
else if (state & NK_WIDGET_STATE_ACTIVED) {
14087 nk_draw_symbol(out, type, *symbol, style->
text_background, sym, 0, font);
14092 nk_do_button_text_symbol(nk_flags *state,
14094 enum nk_symbol_type symbol,
const char *str,
int len, nk_flags align,
14099 struct nk_rect tri = {0,0,0,0};
14105 if (!out || !style || !font)
14108 ret = nk_do_button(state, out, bounds, style, in, behavior, &content);
14109 tri.
y = content.
y + (content.
h/2) - font->
height/2;
14111 if (align & NK_TEXT_ALIGN_LEFT) {
14112 tri.
x = (content.
x + content.
w) - (2 * style->
padding.
x + tri.
w);
14114 }
else tri.
x = content.
x + 2 * style->
padding.
x;
14118 nk_draw_button_text_symbol(out, &bounds, &content, &tri,
14119 *state, style, str, len, symbol, font);
14128 const char *str,
int len,
const struct nk_user_font *font,
14133 background = nk_draw_button(out, bounds, state, style);
14137 text.background = background->
data.
color;
14139 if (state & NK_WIDGET_STATE_HOVER)
14141 else if (state & NK_WIDGET_STATE_ACTIVED)
14151 nk_do_button_text_image(nk_flags *state,
14153 struct nk_image img,
const char* str,
int len, nk_flags align,
14165 if (!out || !font || !style || !str)
14168 ret = nk_do_button(state, out, bounds, style, in, behavior, &content);
14170 icon.w = icon.h = bounds.
h - 2 * style->
padding.
y;
14171 if (align & NK_TEXT_ALIGN_LEFT) {
14172 icon.x = (bounds.
x + bounds.
w) - (2 * style->
padding.
x + icon.w);
14173 icon.x =
NK_MAX(icon.x, 0);
14174 }
else icon.x = bounds.
x + 2 * style->
padding.
x;
14182 nk_draw_button_text_image(out, &bounds, &content, &icon, *state, style, str, len, font, &img);
14192 enum nk_toggle_type {
14199 nk_flags *state,
int active)
14201 nk_widget_state_reset(state);
14217 const struct nk_rect *cursors,
const char *
string,
int len,
14225 if (state & NK_WIDGET_STATE_HOVER) {
14226 background = &style->
hover;
14229 }
else if (state & NK_WIDGET_STATE_ACTIVED) {
14230 background = &style->
hover;
14234 background = &style->
normal;
14250 text.padding.x = 0;
14251 text.padding.y = 0;
14253 nk_widget_text(out, *label,
string, len, &text,
NK_TEXT_LEFT, font);
14260 const struct nk_rect *cursors,
const char *
string,
int len,
14268 if (state & NK_WIDGET_STATE_HOVER) {
14269 background = &style->
hover;
14272 }
else if (state & NK_WIDGET_STATE_ACTIVED) {
14273 background = &style->
hover;
14277 background = &style->
normal;
14293 text.padding.x = 0;
14294 text.padding.y = 0;
14296 nk_widget_text(out, *label,
string, len, &text,
NK_TEXT_LEFT, font);
14300 nk_do_toggle(nk_flags *state,
14302 int *active,
const char *str,
int len,
enum nk_toggle_type type,
14315 if (!out || !style || !font || !active)
14329 select.
h = select.
w;
14330 select.
y = r.
y + r.
h/2.0f - select.
h/2.0f;
14340 label.
x = select.
x + select.
w + style->
spacing;
14341 label.
y = select.
y;
14343 label.
h = select.
w;
14346 was_active = *active;
14347 *active = nk_toggle_behavior(in, bounds, state, *active);
14352 if (type == NK_TOGGLE_CHECK) {
14353 nk_draw_checkbox(out, *state, style, *active, &label, &select, &cursor, str, len, font);
14355 nk_draw_option(out, *state, style, *active, &label, &select, &cursor, str, len, font);
14359 return (was_active != *active);
14371 const char *
string,
int len, nk_flags align,
const struct nk_user_font *font)
14375 text.padding = style->
padding;
14379 if (state & NK_WIDGET_STATE_ACTIVED) {
14380 background = &style->
pressed;
14382 }
else if (state & NK_WIDGET_STATE_HOVER) {
14383 background = &style->
hover;
14386 background = &style->
normal;
14390 if (state & NK_WIDGET_STATE_ACTIVED) {
14393 }
else if (state & NK_WIDGET_STATE_HOVER) {
14406 text.background =
nk_rgba(0,0,0,0);
14409 text.background = background->
data.
color;
14412 nk_widget_text(out, *bounds,
string, len, &text, align, font);
14417 struct nk_rect bounds,
const char *str,
int len, nk_flags align,
int *value,
14432 if (!state || !out || !str || !len || !value || !style || !font)
return 0;
14433 old_value = *
value;
14443 *value = !(*value);
14447 nk_draw_selectable(out, *state, style, *value, &bounds, 0,0, str, len, align, font);
14449 return old_value != *
value;
14454 struct nk_rect bounds,
const char *str,
int len, nk_flags align,
int *value,
14470 if (!state || !out || !str || !len || !value || !style || !font)
return 0;
14471 old_value = *
value;
14479 *value = !(*value);
14482 icon.
w = icon.
h = bounds.
h - 2 * style->
padding.
y;
14483 if (align & NK_TEXT_ALIGN_LEFT) {
14484 icon.
x = (bounds.
x + bounds.
w) - (2 * style->
padding.
x + icon.
w);
14486 }
else icon.
x = bounds.
x + 2 * style->
padding.
x;
14495 nk_draw_selectable(out, *state, style, *value, &bounds, &icon, img, str, len, align, font);
14497 return old_value != *
value;
14507 nk_slider_behavior(nk_flags *state,
struct nk_rect *logical_cursor,
14509 struct nk_rect bounds,
float slider_min,
float slider_max,
float slider_value,
14510 float slider_step,
float slider_steps)
14512 int left_mouse_down;
14513 int left_mouse_click_in_cursor;
14516 nk_widget_state_reset(state);
14521 if (left_mouse_down && left_mouse_click_in_cursor)
14524 const float d = in->
mouse.
pos.
x - (visual_cursor->
x+visual_cursor->
w*0.5f);
14525 const float pxstep = bounds.
w / slider_steps;
14529 if (
NK_ABS(d) >= pxstep) {
14530 const float steps = (float)((
int)(
NK_ABS(d) / pxstep));
14531 slider_value += (d > 0) ? (slider_step*steps) : -(slider_step*steps);
14532 slider_value =
NK_CLAMP(slider_min, slider_value, slider_max);
14533 ratio = (slider_value - slider_min)/slider_step;
14534 logical_cursor->
x = bounds.
x + (logical_cursor->
w * ratio);
14542 if (*state & NK_WIDGET_STATE_HOVER &&
14547 return slider_value;
14553 const struct nk_rect *visual_cursor,
float min,
float value,
float max)
14567 if (state & NK_WIDGET_STATE_ACTIVED) {
14568 background = &style->
active;
14571 }
else if (state & NK_WIDGET_STATE_HOVER) {
14572 background = &style->
hover;
14576 background = &style->
normal;
14583 bar.y = (visual_cursor->
y + visual_cursor->
h/2) - bounds->
h/12;
14585 bar.h = bounds->
h/6;
14588 fill.w = (visual_cursor->
x + (visual_cursor->
w/2.0f)) -
bar.x;
14612 nk_do_slider(nk_flags *state,
14614 float min,
float val,
float max,
float step,
14618 float slider_range;
14621 float slider_value;
14622 float slider_steps;
14623 float cursor_offset;
14625 struct nk_rect visual_cursor;
14626 struct nk_rect logical_cursor;
14630 if (!out || !style)
14645 button.
y = bounds.
y;
14646 button.w = bounds.
h;
14647 button.h = bounds.
h;
14650 button.x = bounds.
x;
14656 button.x = (bounds.
x + bounds.
w) - button.w;
14661 bounds.
x = bounds.
x + button.w + style->
spacing.
x;
14662 bounds.
w = bounds.
w - (2*button.w + 2*style->
spacing.
x);
14670 slider_max =
NK_MAX(min, max);
14671 slider_min =
NK_MIN(min, max);
14672 slider_value =
NK_CLAMP(slider_min, val, slider_max);
14673 slider_range = slider_max - slider_min;
14674 slider_steps = slider_range / step;
14675 cursor_offset = (slider_value - slider_min) / step;
14680 logical_cursor.
h = bounds.
h;
14681 logical_cursor.
w = bounds.
w / slider_steps;
14682 logical_cursor.
x = bounds.
x + (logical_cursor.
w * cursor_offset);
14683 logical_cursor.
y = bounds.
y;
14687 visual_cursor.
y = (bounds.
y + bounds.
h*0.5f) - visual_cursor.
h*0.5f;
14688 visual_cursor.
x = logical_cursor.
x - visual_cursor.
w*0.5f;
14690 slider_value = nk_slider_behavior(state, &logical_cursor, &visual_cursor,
14691 in, bounds, slider_min, slider_max, slider_value, step, slider_steps);
14692 visual_cursor.
x = logical_cursor.
x - visual_cursor.
w*0.5f;
14696 nk_draw_slider(out, *state, style, &bounds, &visual_cursor, slider_min, slider_value, slider_max);
14698 return slider_value;
14707 nk_progress_behavior(nk_flags *state,
const struct nk_input *in,
14708 struct nk_rect r, nk_size max, nk_size value,
int modifiable)
14710 nk_widget_state_reset(state);
14716 if (left_mouse_down && left_mouse_click_in_cursor) {
14718 value = (nk_size)
NK_MAX(0,((
float)max * ratio));
14729 if (!max)
return value;
14730 value =
NK_MIN(value, max);
14737 const struct nk_rect *scursor, nk_size value, nk_size max)
14746 if (state & NK_WIDGET_STATE_ACTIVED) {
14747 background = &style->
active;
14749 }
else if (state & NK_WIDGET_STATE_HOVER){
14750 background = &style->
hover;
14753 background = &style->
normal;
14771 nk_do_progress(nk_flags *state,
14773 nk_size value, nk_size max,
int modifiable,
14777 nk_size prog_value;
14782 if (!out || !style)
return 0;
14788 prog_scale = (float)value / (
float)max;
14789 cursor.w = (bounds.
w - 2) * prog_scale;
14792 prog_value =
NK_MIN(value, max);
14793 prog_value = nk_progress_behavior(state, in, bounds, max, prog_value, modifiable);
14797 nk_draw_progress(out, *state, style, &bounds, &cursor, value, max);
14808 nk_scrollbar_behavior(nk_flags *state,
struct nk_input *in,
14809 int has_scrolling,
const struct nk_rect *scroll,
14811 const struct nk_rect *empty1,
float scroll_offset,
14815 int left_mouse_down;
14816 int left_mouse_click_in_cursor;
14817 float scroll_delta;
14819 nk_widget_state_reset(state);
14820 if (!in)
return scroll_offset;
14829 if (left_mouse_down && left_mouse_click_in_cursor) {
14831 float pixel, delta;
14836 delta = (pixel / scroll->
h) * target;
14837 scroll_offset =
NK_CLAMP(0, scroll_offset + delta, target - scroll->
h);
14838 cursor_y = scroll->
y + ((scroll_offset/target) * scroll->
h);
14843 delta = (pixel / scroll->
w) * target;
14844 scroll_offset =
NK_CLAMP(0, scroll_offset + delta, target - scroll->
w);
14845 cursor_x = scroll->
x + ((scroll_offset/target) * scroll->
w);
14852 scroll_offset =
NK_MAX(0, scroll_offset - scroll->
h);
14853 else scroll_offset =
NK_MAX(0, scroll_offset - scroll->
w);
14858 scroll_offset =
NK_MIN(scroll_offset + scroll->
h, target - scroll->
h);
14859 else scroll_offset =
NK_MIN(scroll_offset + scroll->
w, target - scroll->
w);
14860 }
else if (has_scrolling) {
14861 if ((scroll_delta < 0 || (scroll_delta > 0))) {
14863 scroll_offset = scroll_offset + scroll_step * (-scroll_delta);
14865 scroll_offset =
NK_CLAMP(0, scroll_offset, target - scroll->
h);
14866 else scroll_offset =
NK_CLAMP(0, scroll_offset, target - scroll->
w);
14872 if (o ==
NK_VERTICAL) scroll_offset = target - scroll->
h;
14879 return scroll_offset;
14885 const struct nk_rect *scroll)
14891 if (state & NK_WIDGET_STATE_ACTIVED) {
14892 background = &style->
active;
14894 }
else if (state & NK_WIDGET_STATE_HOVER) {
14895 background = &style->
hover;
14898 background = &style->
normal;
14918 nk_do_scrollbarv(nk_flags *state,
14920 float offset,
float target,
float step,
float button_pixel_inc,
14929 float scroll_offset;
14931 float scroll_ratio;
14936 if (!out || !style)
return 0;
14940 if (target <= scroll.
h)
return 0;
14948 button.
x = scroll.
x;
14949 button.w = scroll.
w;
14950 button.h = scroll.
w;
14952 scroll_h =
NK_MAX(scroll.
h - 2 * button.h,0);
14953 scroll_step =
NK_MIN(step, button_pixel_inc);
14956 button.y = scroll.
y;
14957 if (nk_do_button_symbol(&ws, out, button, style->
dec_symbol,
14959 offset = offset - scroll_step;
14962 button.y = scroll.
y + scroll.
h - button.h;
14963 if (nk_do_button_symbol(&ws, out, button, style->
inc_symbol,
14965 offset = offset + scroll_step;
14967 scroll.
y = scroll.
y + button.h;
14968 scroll.
h = scroll_h;
14972 scroll_step =
NK_MIN(step, scroll.
h);
14973 scroll_offset =
NK_CLAMP(0, offset, target - scroll.
h);
14974 scroll_ratio = scroll.
h / target;
14975 scroll_off = scroll_offset / target;
14979 cursor.y = scroll.
y + (scroll_off * scroll.
h) + style->
border + style->
padding.
y;
14984 empty_north.x = scroll.
x;
14985 empty_north.y = scroll.
y;
14986 empty_north.w = scroll.
w;
14987 empty_north.h =
NK_MAX(cursor.y - scroll.
y, 0);
14989 empty_south.x = scroll.
x;
14990 empty_south.y = cursor.y + cursor.h;
14991 empty_south.w = scroll.
w;
14992 empty_south.h =
NK_MAX((scroll.
y + scroll.
h) - (cursor.y + cursor.h), 0);
14995 scroll_offset = nk_scrollbar_behavior(state, in, has_scrolling, &scroll, &cursor,
14996 &empty_north, &empty_south, scroll_offset, target, scroll_step,
NK_VERTICAL);
14997 scroll_off = scroll_offset / target;
15002 nk_draw_scrollbar(out, *state, style, &scroll, &cursor);
15004 return scroll_offset;
15008 nk_do_scrollbarh(nk_flags *state,
15010 float offset,
float target,
float step,
float button_pixel_inc,
15019 float scroll_offset;
15021 float scroll_ratio;
15025 if (!out || !style)
return 0;
15029 scroll.
w =
NK_MAX(scroll.
w, 2 * scroll.
h);
15030 if (target <= scroll.
w)
return 0;
15037 button.
y = scroll.
y;
15038 button.w = scroll.
h;
15039 button.h = scroll.
h;
15041 scroll_w = scroll.
w - 2 * button.w;
15042 scroll_step =
NK_MIN(step, button_pixel_inc);
15045 button.x = scroll.
x;
15046 if (nk_do_button_symbol(&ws, out, button, style->
dec_symbol,
15048 offset = offset - scroll_step;
15051 button.x = scroll.
x + scroll.
w - button.w;
15052 if (nk_do_button_symbol(&ws, out, button, style->
inc_symbol,
15054 offset = offset + scroll_step;
15056 scroll.
x = scroll.
x + button.w;
15057 scroll.
w = scroll_w;
15061 scroll_step =
NK_MIN(step, scroll.
w);
15062 scroll_offset =
NK_CLAMP(0, offset, target - scroll.
w);
15063 scroll_ratio = scroll.
w / target;
15064 scroll_off = scroll_offset / target;
15067 cursor.w = (scroll_ratio * scroll.
w) - (2*style->
border + 2*style->
padding.
x);
15068 cursor.x = scroll.
x + (scroll_off * scroll.
w) + style->
border + style->
padding.
x;
15073 empty_west.x = scroll.
x;
15074 empty_west.y = scroll.
y;
15075 empty_west.w = cursor.x - scroll.
x;
15076 empty_west.h = scroll.
h;
15078 empty_east.x = cursor.x + cursor.w;
15079 empty_east.y = scroll.
y;
15080 empty_east.w = (scroll.
x + scroll.
w) - (cursor.x + cursor.w);
15081 empty_east.h = scroll.
h;
15084 scroll_offset = nk_scrollbar_behavior(state, in, has_scrolling, &scroll, &cursor,
15085 &empty_west, &empty_east, scroll_offset, target, scroll_step,
NK_HORIZONTAL);
15086 scroll_off = scroll_offset / target;
15087 cursor.x = scroll.
x + (scroll_off * scroll.
w);
15091 nk_draw_scrollbar(out, *state, style, &scroll, &cursor);
15093 return scroll_offset;
15108 if (unicode > 128)
return nk_false;
15116 if ((unicode < '0' || unicode >
'9') && unicode !=
'.' && unicode !=
'-')
15125 if ((unicode < '0' || unicode >
'9') && unicode !=
'-')
15134 if ((unicode < '0' || unicode >
'9') &&
15135 (unicode < 'a' || unicode >
'f') &&
15136 (unicode < 'A' || unicode >
'F'))
15145 if (unicode < '0' || unicode >
'7')
15154 if (unicode !=
'0' && unicode !=
'1')
15166 const struct nk_style_edit *style,
float pos_x,
float pos_y,
15167 float x_offset,
const char *text,
int byte_len,
float row_height,
15169 struct nk_color foreground,
int is_selected)
15174 if (!text || !byte_len || !out || !style)
return;
15176 {
int glyph_len = 0;
15177 nk_rune unicode = 0;
15179 float line_width = 0;
15181 const char *line = text;
15182 float line_offset = 0;
15183 int line_count = 0;
15187 txt.background = background;
15188 txt.text = foreground;
15190 glyph_len =
nk_utf_decode(text+text_len, &unicode, byte_len-text_len);
15191 if (!glyph_len)
return;
15192 while ((text_len < byte_len) && glyph_len)
15194 if (unicode ==
'\n') {
15197 label.
y = pos_y + line_offset;
15198 label.
h = row_height;
15199 label.
w = line_width;
15202 label.
x += x_offset;
15206 nk_widget_text(out, label, line, (
int)((text + text_len) - line),
15212 line = text + text_len;
15213 line_offset += row_height;
15214 glyph_len =
nk_utf_decode(text + text_len, &unicode, (
int)(byte_len-text_len));
15217 if (unicode ==
'\r') {
15219 glyph_len =
nk_utf_decode(text + text_len, &unicode, byte_len-text_len);
15223 line_width += (float)glyph_width;
15224 text_len += glyph_len;
15225 glyph_len =
nk_utf_decode(text + text_len, &unicode, byte_len-text_len);
15228 if (line_width > 0) {
15231 label.
y = pos_y + line_offset;
15232 label.
h = row_height;
15233 label.
w = line_width;
15236 label.
x += x_offset;
15240 nk_widget_text(out, label, line, (
int)((text + text_len) - line),
15254 char prev_state = 0;
15255 char is_hovered = 0;
15256 char select_all = 0;
15257 char cursor_follow = 0;
15264 if (!state || !out || !style)
15277 old_clip = out->
clip;
15278 nk_unify(&clip, &old_clip, area.
x, area.y, area.x + area.w, area.y + area.h);
15281 prev_state = (char)edit->
active;
15285 bounds.
x, bounds.
y, bounds.
w, bounds.
h);
15289 if (!prev_state && edit->
active) {
15292 nk_textedit_clear_state(edit, type, filter);
15306 if (prev_state != edit->
active)
15322 nk_textedit_click(edit, mouse_x, mouse_y, font, row_height);
15325 nk_textedit_drag(edit, mouse_x, mouse_y, font, row_height);
15335 int old_mode = edit->
mode;
15339 nk_textedit_key(edit, (
enum nk_keys)i, shift_mod, font, row_height);
15343 if (old_mode != edit->
mode) {
15376 int begin =
NK_MIN(b, e);
15381 if (cut && !(flags & NK_EDIT_READ_ONLY)){
15389 if (paste && (flags & NK_EDIT_CLIPBOARD) && edit->
clip.
paste) {
15405 else nk_widget_state_reset(state);
15416 if (*state & NK_WIDGET_STATE_ACTIVED)
15417 background = &style->
active;
15418 else if (*state & NK_WIDGET_STATE_HOVER)
15419 background = &style->
hover;
15420 else background = &style->
normal;
15431 int total_lines = 1;
15435 const char *cursor_ptr = 0;
15436 const char *select_begin_ptr = 0;
15437 const char *select_end_ptr = 0;
15448 float line_width = 0.0f;
15454 nk_rune unicode = 0;
15464 while ((text_len < len) && glyph_len)
15467 if (!cursor_ptr && glyphs == edit->
cursor)
15472 const char *remaining;
15475 cursor_pos.
y = (float)(total_lines-1) * row_height;
15476 row_size = nk_text_calculate_text_bounds(font, text+row_begin,
15477 text_len-row_begin, row_height, &remaining,
15478 &out_offset, &glyph_offset, NK_STOP_ON_NEW_LINE);
15479 cursor_pos.
x = row_size.x;
15480 cursor_ptr = text + text_len;
15485 glyphs == selection_begin)
15490 const char *remaining;
15493 selection_offset_start.
y = (float)(
NK_MAX(total_lines-1,0)) * row_height;
15494 row_size = nk_text_calculate_text_bounds(font, text+row_begin,
15495 text_len-row_begin, row_height, &remaining,
15496 &out_offset, &glyph_offset, NK_STOP_ON_NEW_LINE);
15497 selection_offset_start.
x = row_size.x;
15498 select_begin_ptr = text + text_len;
15503 glyphs == selection_end)
15508 const char *remaining;
15511 selection_offset_end.
y = (float)(total_lines-1) * row_height;
15512 row_size = nk_text_calculate_text_bounds(font, text+row_begin,
15513 text_len-row_begin, row_height, &remaining,
15514 &out_offset, &glyph_offset, NK_STOP_ON_NEW_LINE);
15515 selection_offset_end.
x = row_size.x;
15516 select_end_ptr = text + text_len;
15518 if (unicode ==
'\n') {
15519 text_size.
x =
NK_MAX(text_size.
x, line_width);
15524 row_begin = text_len;
15525 glyph_len =
nk_utf_decode(text + text_len, &unicode, len-text_len);
15531 text_len += glyph_len;
15532 line_width += (float)glyph_width;
15534 glyph_len =
nk_utf_decode(text + text_len, &unicode, len-text_len);
15536 text+text_len, glyph_len);
15539 text_size.
y = (float)total_lines * row_height;
15543 cursor_pos.
x = line_width;
15544 cursor_pos.
y = text_size.
y - row_height;
15554 const float scroll_increment = area.w * 0.25f;
15561 if (flags & NK_EDIT_MULTILINE) {
15571 if (flags & NK_EDIT_MULTILINE)
15575 float scroll_target;
15576 float scroll_offset;
15585 scroll_step = scroll.
h * 0.10f;
15586 scroll_inc = scroll.
h * 0.01f;
15587 scroll_target = text_size.
y;
15588 edit->
scrollbar.
y = nk_do_scrollbarv(&ws, out, scroll, 0,
15589 scroll_offset, scroll_target, scroll_step, scroll_inc,
15595 {
struct nk_color background_color;
15597 struct nk_color sel_background_color;
15600 struct nk_color cursor_text_color;
15605 if (*state & NK_WIDGET_STATE_ACTIVED) {
15606 background = &style->
active;
15612 }
else if (*state & NK_WIDGET_STATE_HOVER) {
15613 background = &style->
hover;
15620 background = &style->
normal;
15628 background_color =
nk_rgba(0,0,0,0);
15629 else background_color = background->
data.
color;
15636 nk_edit_draw_text(out, style, area.x - edit->
scrollbar.
x,
15637 area.y - edit->
scrollbar.
y, 0, begin, l, row_height, font,
15638 background_color, text_color,
nk_false);
15644 NK_ASSERT(select_begin_ptr);
15645 nk_edit_draw_text(out, style, area.x - edit->
scrollbar.
x,
15646 area.y - edit->
scrollbar.
y, 0, begin, (
int)(select_begin_ptr - begin),
15647 row_height, font, background_color, text_color,
nk_false);
15651 NK_ASSERT(select_begin_ptr);
15652 if (!select_end_ptr) {
15656 nk_edit_draw_text(out, style,
15658 area.y + selection_offset_start.
y - edit->
scrollbar.
y,
15659 selection_offset_start.
x,
15660 select_begin_ptr, (
int)(select_end_ptr - select_begin_ptr),
15661 row_height, font, sel_background_color, sel_text_color,
nk_true);
15664 selection_end < edit->
string.len))
15667 const char *begin = select_end_ptr;
15670 NK_ASSERT(select_end_ptr);
15671 nk_edit_draw_text(out, style,
15673 area.y + selection_offset_end.
y - edit->
scrollbar.
y,
15674 selection_offset_end.
x,
15675 begin, (
int)(end - begin), row_height, font,
15676 background_color, text_color,
nk_true);
15684 (cursor_ptr && *cursor_ptr ==
'\n')) {
15688 cursor.h = font->
height;
15689 cursor.x = area.x + cursor_pos.
x - edit->
scrollbar.
x;
15690 cursor.y = area.y + cursor_pos.
y + row_height/2.0f - cursor.h/2.0f;
15700 NK_ASSERT(cursor_ptr);
15706 label.
h = row_height;
15709 txt.background = cursor_color;;
15710 txt.text = cursor_text_color;
15712 nk_widget_text(out, label, cursor_ptr, glyph_len, &txt,
NK_TEXT_LEFT, font);
15724 if (*state & NK_WIDGET_STATE_ACTIVED) {
15725 background = &style->
active;
15727 }
else if (*state & NK_WIDGET_STATE_HOVER) {
15728 background = &style->
hover;
15731 background = &style->
normal;
15735 background_color =
nk_rgba(0,0,0,0);
15736 else background_color = background->
data.
color;
15737 nk_edit_draw_text(out, style, area.x - edit->
scrollbar.
x,
15738 area.y - edit->
scrollbar.
y, 0, begin, l, row_height, font,
15739 background_color, text_color,
nk_false);
15750 enum nk_property_status {
15751 NK_PROPERTY_DEFAULT,
15755 enum nk_property_filter {
15759 enum nk_property_kind {
15764 union nk_property {
15769 struct nk_property_variant {
15770 enum nk_property_kind kind;
15771 union nk_property value;
15772 union nk_property min_value;
15773 union nk_property max_value;
15774 union nk_property step;
15778 nk_drag_behavior(nk_flags *state,
const struct nk_input *in,
15779 struct nk_rect drag,
struct nk_property_variant *variant,
15780 float inc_per_pixel)
15783 int left_mouse_click_in_cursor = in &&
15786 nk_widget_state_reset(state);
15790 if (left_mouse_down && left_mouse_click_in_cursor) {
15791 float delta, pixels;
15793 delta = pixels * inc_per_pixel;
15794 switch (variant->kind) {
15796 case NK_PROPERTY_INT:
15797 variant->value.i = variant->value.i + (
int)delta;
15798 variant->value.i =
NK_CLAMP(variant->min_value.i, variant->value.i, variant->max_value.i);
15800 case NK_PROPERTY_FLOAT:
15801 variant->value.f = variant->value.f + (float)delta;
15802 variant->value.f =
NK_CLAMP(variant->min_value.f, variant->value.f, variant->max_value.f);
15804 case NK_PROPERTY_DOUBLE:
15805 variant->value.d = variant->value.d + (double)delta;
15806 variant->value.d =
NK_CLAMP(variant->min_value.d, variant->value.d, variant->max_value.d);
15818 nk_property_behavior(nk_flags *ws,
const struct nk_input *in,
15820 struct nk_rect empty,
int *state,
struct nk_property_variant *variant,
15821 float inc_per_pixel)
15823 if (in && *state == NK_PROPERTY_DEFAULT) {
15825 *state = NK_PROPERTY_EDIT;
15827 *state = NK_PROPERTY_DRAG;
15829 *state = NK_PROPERTY_DRAG;
15831 if (*state == NK_PROPERTY_DRAG) {
15832 nk_drag_behavior(ws, in, property, variant, inc_per_pixel);
15833 if (!(*ws & NK_WIDGET_STATE_ACTIVED)) *state = NK_PROPERTY_DEFAULT;
15839 const struct nk_rect *bounds,
const struct nk_rect *label, nk_flags state,
15840 const char *name,
int len,
const struct nk_user_font *font)
15846 if (state & NK_WIDGET_STATE_ACTIVED) {
15847 background = &style->
active;
15849 }
else if (state & NK_WIDGET_STATE_HOVER) {
15850 background = &style->
hover;
15853 background = &style->
normal;
15860 text.background =
nk_rgba(0,0,0,0);
15862 text.background = background->
data.
color;
15873 nk_do_property(nk_flags *ws,
15875 const char *name,
struct nk_property_variant *variant,
15876 float inc_per_pixel,
char *buffer,
int *len,
15877 int *state,
int *cursor,
int *select_begin,
int *select_end,
15879 enum nk_property_filter filter,
struct nk_input *in,
15888 int num_len, name_len;
15905 left.y =
property.y + style->
border +
property.h/2.0f - left.h/2;
15910 label.
x = left.x + left.w + style->
padding.
x;
15911 label.
w = (float)size + 2 * style->
padding.
x;
15919 right.x =
property.x +
property.w - (right.w + style->
padding.
x);
15922 if (*state == NK_PROPERTY_EDIT) {
15928 switch (variant->kind) {
15930 case NK_PROPERTY_INT:
15931 nk_itoa(
string, variant->value.i);
15934 case NK_PROPERTY_FLOAT:
15935 nk_dtoa(
string, (
double)variant->value.f);
15938 case NK_PROPERTY_DOUBLE:
15939 nk_dtoa(
string, variant->value.d);
15948 edit.
w = (float)size + 2 * style->
padding.
x;
15949 edit.
w =
NK_MIN(edit.
w, right.x - (label.
x + label.
w));
15950 edit.
x = right.x - (edit.
w + style->
padding.
x);
15951 edit.
y =
property.y + style->
border;
15952 edit.
h =
property.h - (2 * style->
border);
15955 empty.
w = edit.
x - (label.
x + label.
w);
15956 empty.
x = label.
x + label.
w;
15957 empty.
y =
property.y;
15958 empty.
h =
property.h;
15961 old = (*state == NK_PROPERTY_EDIT);
15962 nk_property_behavior(ws, in, property, label, edit, empty, state, variant, inc_per_pixel);
15966 nk_draw_property(out, style, &property, &label, *ws, name, name_len, font);
15970 if (nk_do_button_symbol(ws, out, left, style->
sym_left, behavior, &style->
dec_button, in, font)) {
15971 switch (variant->kind) {
15973 case NK_PROPERTY_INT:
15974 variant->value.i =
NK_CLAMP(variant->min_value.i, variant->value.i - variant->step.i, variant->max_value.i);
break;
15975 case NK_PROPERTY_FLOAT:
15976 variant->value.f =
NK_CLAMP(variant->min_value.f, variant->value.f - variant->step.f, variant->max_value.f);
break;
15977 case NK_PROPERTY_DOUBLE:
15978 variant->value.d =
NK_CLAMP(variant->min_value.d, variant->value.d - variant->step.d, variant->max_value.d);
break;
15983 if (nk_do_button_symbol(ws, out, right, style->
sym_right, behavior, &style->
inc_button, in, font)) {
15984 switch (variant->kind) {
15986 case NK_PROPERTY_INT:
15987 variant->value.i =
NK_CLAMP(variant->min_value.i, variant->value.i + variant->step.i, variant->max_value.i);
break;
15988 case NK_PROPERTY_FLOAT:
15989 variant->value.f =
NK_CLAMP(variant->min_value.f, variant->value.f + variant->step.f, variant->max_value.f);
break;
15990 case NK_PROPERTY_DOUBLE:
15991 variant->value.d =
NK_CLAMP(variant->min_value.d, variant->value.d + variant->step.d, variant->max_value.d);
break;
15995 if (old != NK_PROPERTY_EDIT && (*state == NK_PROPERTY_EDIT)) {
15997 NK_MEMCPY(buffer, dst, (nk_size)*length);
16003 }
else active = (*state == NK_PROPERTY_EDIT);
16007 text_edit->
active = (
unsigned char)active;
16017 nk_do_edit(ws, out, edit,
NK_EDIT_FIELD|NK_EDIT_AUTO_SELECT,
16018 filters[filter], text_edit, &style->
edit, (*state == NK_PROPERTY_EDIT) ? in: 0, font);
16021 active = text_edit->
active;
16022 *cursor = text_edit->
cursor;
16029 if (old && !active) {
16031 *state = NK_PROPERTY_DEFAULT;
16032 buffer[*len] =
'\0';
16033 switch (variant->kind) {
16035 case NK_PROPERTY_INT:
16036 variant->value.i =
nk_strtoi(buffer, 0);
16037 variant->value.i =
NK_CLAMP(variant->min_value.i, variant->value.i, variant->max_value.i);
16039 case NK_PROPERTY_FLOAT:
16041 variant->value.f =
nk_strtof(buffer, 0);
16042 variant->value.f =
NK_CLAMP(variant->min_value.f, variant->value.f, variant->max_value.f);
16044 case NK_PROPERTY_DOUBLE:
16046 variant->value.d =
nk_strtod(buffer, 0);
16047 variant->value.d =
NK_CLAMP(variant->min_value.d, variant->value.d, variant->max_value.d);
16058 nk_color_picker_behavior(nk_flags *state,
16064 int value_changed = 0;
16065 int hsv_changed = 0;
16069 NK_ASSERT(hue_bar);
16077 value_changed = hsv_changed = 1;
16083 value_changed = hsv_changed = 1;
16093 nk_widget_state_reset(state);
16098 if (value_changed) {
16099 color->
a = (
nk_byte)(hsva[3] * 255.0f);
16110 return value_changed;
16122 const float crosshair_size = 7.0f;
16130 NK_ASSERT(hue_bar);
16134 for (i = 0; i < 6; ++i) {
16141 {255, 0, 255, 255},
16145 nk_rect(hue_bar->
x, hue_bar->
y + (
float)i * (hue_bar->
h/6.0f) + 0.5f,
16146 hue_bar->
w, (hue_bar->
h/6.0f) + 0.5f), hue_colors[i], hue_colors[i],
16147 hue_colors[i+1], hue_colors[i+1]);
16149 line_y = (float)(
int)(hue_bar->
y + hsva[0] * matrix->
h + 0.5f);
16151 line_y, 1,
nk_rgb(255,255,255));
16156 line_y = (float)(
int)(alpha_bar->
y + (1.0f - alpha) * matrix->
h + 0.5f);
16160 line_y, 1,
nk_rgb(255,255,255));
16164 temp =
nk_hsv_f(hsva[0], 1.0f, 1.0f);
16169 {
struct nk_vec2 p;
float S = hsva[1];
float V = hsva[2];
16170 p.
x = (float)(
int)(matrix->
x + S * matrix->
w);
16171 p.y = (float)(
int)(matrix->
y + (1.0f - V) * matrix->
h);
16172 nk_stroke_line(o, p.x - crosshair_size, p.y, p.x-2, p.y, 1.0f, white);
16173 nk_stroke_line(o, p.x + crosshair_size + 1, p.y, p.x+3, p.y, 1.0f, white);
16174 nk_stroke_line(o, p.x, p.y + crosshair_size + 1, p.x, p.y+3, 1.0f, white);
16175 nk_stroke_line(o, p.x, p.y - crosshair_size, p.x, p.y-2, 1.0f, white);}
16179 nk_do_color_picker(nk_flags *state,
16195 if (!out || !color || !state || !font)
16199 bounds.
x += padding.
x;
16200 bounds.
y += padding.
x;
16201 bounds.
w -= 2 * padding.
x;
16202 bounds.
h -= 2 * padding.
y;
16204 matrix.
x = bounds.
x;
16205 matrix.
y = bounds.
y;
16206 matrix.
h = bounds.
h;
16207 matrix.
w = bounds.
w - (3 * padding.
x + 2 * bar_w);
16210 hue_bar.
y = bounds.
y;
16211 hue_bar.
h = matrix.
h;
16212 hue_bar.
x = matrix.
x + matrix.
w + padding.
x;
16214 alpha_bar.
x = hue_bar.
x + hue_bar.
w + padding.
x;
16215 alpha_bar.
y = bounds.
y;
16216 alpha_bar.
w = bar_w;
16217 alpha_bar.
h = matrix.
h;
16219 ret = nk_color_picker_behavior(state, &bounds, &matrix, &hue_bar,
16220 (fmt ==
NK_RGBA) ? &alpha_bar:0, color, in);
16221 nk_draw_color_picker(out, &matrix, &hue_bar, (fmt ==
NK_RGBA) ? &alpha_bar:0, *color);
16231 #define NK_COLOR_MAP(NK_COLOR)\
16232 NK_COLOR(NK_COLOR_TEXT, 175,175,175,255) \
16233 NK_COLOR(NK_COLOR_WINDOW, 45, 45, 45, 255) \
16234 NK_COLOR(NK_COLOR_HEADER, 40, 40, 40, 255) \
16235 NK_COLOR(NK_COLOR_BORDER, 65, 65, 65, 255) \
16236 NK_COLOR(NK_COLOR_BUTTON, 50, 50, 50, 255) \
16237 NK_COLOR(NK_COLOR_BUTTON_HOVER, 40, 40, 40, 255) \
16238 NK_COLOR(NK_COLOR_BUTTON_ACTIVE, 35, 35, 35, 255) \
16239 NK_COLOR(NK_COLOR_TOGGLE, 100,100,100,255) \
16240 NK_COLOR(NK_COLOR_TOGGLE_HOVER, 120,120,120,255) \
16241 NK_COLOR(NK_COLOR_TOGGLE_CURSOR, 45, 45, 45, 255) \
16242 NK_COLOR(NK_COLOR_SELECT, 45, 45, 45, 255) \
16243 NK_COLOR(NK_COLOR_SELECT_ACTIVE, 35, 35, 35,255) \
16244 NK_COLOR(NK_COLOR_SLIDER, 38, 38, 38, 255) \
16245 NK_COLOR(NK_COLOR_SLIDER_CURSOR, 100,100,100,255) \
16246 NK_COLOR(NK_COLOR_SLIDER_CURSOR_HOVER, 120,120,120,255) \
16247 NK_COLOR(NK_COLOR_SLIDER_CURSOR_ACTIVE, 150,150,150,255) \
16248 NK_COLOR(NK_COLOR_PROPERTY, 38, 38, 38, 255) \
16249 NK_COLOR(NK_COLOR_EDIT, 38, 38, 38, 255) \
16250 NK_COLOR(NK_COLOR_EDIT_CURSOR, 175,175,175,255) \
16251 NK_COLOR(NK_COLOR_COMBO, 45, 45, 45, 255) \
16252 NK_COLOR(NK_COLOR_CHART, 120,120,120,255) \
16253 NK_COLOR(NK_COLOR_CHART_COLOR, 45, 45, 45, 255) \
16254 NK_COLOR(NK_COLOR_CHART_COLOR_HIGHLIGHT,255, 0, 0, 255) \
16255 NK_COLOR(NK_COLOR_SCROLLBAR, 40, 40, 40, 255) \
16256 NK_COLOR(NK_COLOR_SCROLLBAR_CURSOR, 100,100,100,255) \
16257 NK_COLOR(NK_COLOR_SCROLLBAR_CURSOR_HOVER,120,120,120,255) \
16258 NK_COLOR(NK_COLOR_SCROLLBAR_CURSOR_ACTIVE,150,150,150,255) \
16259 NK_COLOR(NK_COLOR_TAB_HEADER, 40, 40, 40,255)
16263 #define NK_COLOR(a,b,c,d,e) {b,c,d,e},
16264 NK_COLOR_MAP(NK_COLOR)
16269 #define NK_COLOR(a,b,c,d,e) #a,
16270 NK_COLOR_MAP(NK_COLOR)
16275 {
return nk_color_names[c];}
16306 style = &ctx->
style;
16307 table = (!table) ? nk_default_color_style: table;
16310 text = &style->
text;
16315 button = &style->
button;
16395 toggle = &style->
option;
16436 slider = &style->
slider;
16547 edit = &style->
edit;
16585 property->padding =
nk_vec2(4,4);
16586 property->border = 1;
16587 property->rounding = 10;
16588 property->draw_begin = 0;
16589 property->draw_end = 0;
16636 chart = &style->
chart;
16647 combo = &style->
combo;
16835 style = &ctx->
style;
16843 struct nk_config_stack_user_font *font_stack;
16844 struct nk_config_stack_user_font_element *element;
16847 if (!ctx)
return 0;
16850 NK_ASSERT(font_stack->head < (
int)
NK_LEN(font_stack->elements));
16851 if (font_stack->head >= (
int)
NK_LEN(font_stack->elements))
16854 element = &font_stack->elements[font_stack->head++];
16864 struct nk_config_stack_user_font *font_stack;
16865 struct nk_config_stack_user_font_element *element;
16868 if (!ctx)
return 0;
16871 NK_ASSERT(font_stack->head > 0);
16872 if (font_stack->head < 1)
16875 element = &font_stack->elements[--font_stack->head];
16876 *element->address = element->old_value;
16880 #define NK_STYLE_PUSH_IMPLEMENATION(prefix, type, stack) \
16881 nk_style_push_##type(struct nk_context *ctx, prefix##_##type *address, prefix##_##type value)\
16883 struct nk_config_stack_##type * type_stack;\
16884 struct nk_config_stack_##type##_element *element;\
16886 if (!ctx) return 0;\
16887 type_stack = &ctx->stacks.stack;\
16888 NK_ASSERT(type_stack->head < (int)NK_LEN(type_stack->elements));\
16889 if (type_stack->head >= (int)NK_LEN(type_stack->elements))\
16891 element = &type_stack->elements[type_stack->head++];\
16892 element->address = address;\
16893 element->old_value = *address;\
16898 #define NK_STYLE_POP_IMPLEMENATION(type, stack) \
16899 nk_style_pop_##type(struct nk_context *ctx)\
16901 struct nk_config_stack_##type *type_stack;\
16902 struct nk_config_stack_##type##_element *element;\
16904 if (!ctx) return 0;\
16905 type_stack = &ctx->stacks.stack;\
16906 NK_ASSERT(type_stack->head > 0);\
16907 if (type_stack->head < 1)\
16909 element = &type_stack->elements[--type_stack->head];\
16910 *element->address = element->old_value;\
16914 NK_API int NK_STYLE_PUSH_IMPLEMENATION(
struct nk, style_item, style_items)
16915 NK_API int NK_STYLE_PUSH_IMPLEMENATION(nk,
float, floats)
16916 NK_API int NK_STYLE_PUSH_IMPLEMENATION(struct nk, vec2, vectors)
16917 NK_API int NK_STYLE_PUSH_IMPLEMENATION(nk,flags, flags)
16918 NK_API int NK_STYLE_PUSH_IMPLEMENATION(struct nk,color, colors)
16920 NK_API int NK_STYLE_POP_IMPLEMENATION(style_item, style_items)
16921 NK_API int NK_STYLE_POP_IMPLEMENATION(
float,floats)
16922 NK_API int NK_STYLE_POP_IMPLEMENATION(vec2, vectors)
16923 NK_API int NK_STYLE_POP_IMPLEMENATION(flags,flags)
16924 NK_API int NK_STYLE_POP_IMPLEMENATION(color,colors)
16931 if (!ctx)
return 0;
16932 style = &ctx->style;
16959 style = &ctx->
style;
16970 style = &ctx->
style;
16972 style->
cursors[i] = &cursors[i];
16983 unsigned int capacity)
16985 nk_zero(pool,
sizeof(*pool));
16986 pool->
alloc = *alloc;
16993 nk_pool_free(
struct nk_pool *pool)
17006 nk_pool_init_fixed(
struct nk_pool *pool,
void *memory, nk_size size)
17008 nk_zero(pool,
sizeof(*pool));
17009 NK_ASSERT(size >=
sizeof(
struct nk_page));
17010 if (size <
sizeof(
struct nk_page))
return;
17018 nk_pool_alloc(
struct nk_pool *pool)
17024 if (!pool->
pages) {
17025 NK_ASSERT(pool->
pages);
17031 nk_size size =
sizeof(
struct nk_page);
17032 size += NK_POOL_DEFAULT_CAPACITY *
sizeof(
union nk_page_data);
17034 page->next = pool->
pages;
17035 pool->
pages = page;
17064 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
17065 nk_draw_list_init(&ctx->draw_list);
17069 #ifdef NK_INCLUDE_DEFAULT_ALLOCATOR
17075 alloc.
alloc = nk_malloc;
17076 alloc.
free = nk_mfree;
17077 return nk_init(ctx, &alloc, font);
17086 if (!memory)
return 0;
17087 nk_setup(ctx, font);
17099 if (!cmds || !pool)
return 0;
17101 nk_setup(ctx, font);
17109 nk_pool_init(&ctx->
pool, alloc, NK_POOL_DEFAULT_CAPACITY);
17120 if (!alloc)
return 0;
17121 nk_setup(ctx, font);
17123 nk_pool_init(&ctx->
pool, alloc, NK_POOL_DEFAULT_CAPACITY);
17128 #ifdef NK_INCLUDE_COMMAND_USERDATA
17130 nk_set_user_data(
struct nk_context *ctx, nk_handle handle)
17133 ctx->userdata = handle;
17146 nk_pool_free(&ctx->
pool);
17179 #ifdef NK_INCLUDE_VERTEX_BUFFER_OUTPUT
17180 nk_draw_list_clear(&ctx->draw_list);
17201 nk_free_window(ctx, iter->
popup.
win);
17209 if (it->
seq != ctx->
seq) {
17210 nk_remove_table(iter, it);
17212 nk_free_table(ctx, it);
17222 nk_remove_window(ctx, iter);
17223 nk_free_window(ctx, iter);
17225 }
else iter = iter->
next;
17240 if (!ctx || !buffer)
return;
17244 buffer->
clip = nk_null_rect;
17252 nk_start_buffer(ctx, &win->
buffer);
17261 if (!ctx || !win)
return;
17278 if (!ctx || !win)
return;
17290 if (!ctx || !buffer)
return;
17303 if (!ctx || !win)
return;
17304 nk_finish_buffer(ctx, &win->
buffer);
17310 parent_last->
next = buf->
end;
17318 nk_byte *buffer = 0;
17327 nk_start_buffer(ctx, &ctx->
overlay);
17331 mouse_bounds.w = cursor->size.x;
17332 mouse_bounds.h = cursor->size.y;
17335 nk_finish_buffer(ctx, &ctx->
overlay);
17340 while (iter != 0) {
17355 while (iter != 0) {
17381 if (!ctx)
return 0;
17382 if (!ctx->
count)
return 0;
17393 if (!iter)
return 0;
17403 if (!ctx || !cmd || !ctx->
count)
return 0;
17416 nk_panel_has_header(nk_flags flags,
const char *title)
17441 nk_panel_get_border(
const struct nk_style *style, nk_flags flags,
17467 case NK_PANEL_MENU:
return style->window.menu_border_color;
17494 struct nk_vec2 scrollbar_size;
17495 struct nk_vec2 panel_padding;
17508 style = &ctx->
style;
17509 font = style->
font;
17514 #ifdef NK_INCLUDE_COMMAND_USERDATA
17519 panel_padding = nk_panel_get_padding(style, panel_type);
17523 int left_mouse_down;
17524 int left_mouse_click_in_cursor;
17531 if (nk_panel_has_header(win->
flags, title)) {
17534 }
else header.h = panel_padding.y;
17540 if (left_mouse_down && left_mouse_click_in_cursor) {
17550 layout->
type = panel_type;
17553 layout->
bounds.
x += panel_padding.x;
17554 layout->
bounds.
w -= 2*panel_padding.x;
17555 if (win->
flags & NK_WINDOW_BORDER) {
17556 layout->
border = nk_panel_get_border(style, win->
flags, panel_type);
17558 }
else layout->
border = 0;
17572 layout->
bounds.
w -= scrollbar_size.x;
17573 if (!nk_panel_is_nonblock(panel_type)) {
17581 if (nk_panel_has_header(win->
flags, title))
17596 layout->
bounds.
y += header.h;
17597 layout->
bounds.
h -= header.h;
17598 layout->
at_y += header.h;
17601 if (ctx->
active == win) {
17615 text.background =
nk_rgba(0,0,0,0);
17618 text.background = background->
data.
color;
17626 button.w = button.h;
17637 if (nk_do_button_symbol(&ws, &win->
buffer, button,
17650 button.x = (header.w + header.x) - button.w;
17657 button.x = header.x;
17670 struct nk_rect label = {0,0,0,0};
17679 label.
w =
NK_CLAMP(0, label.
w, header.x + header.w - label.
x);
17680 nk_widget_text(out, label,(
const char*)title, text_len, &text,
NK_TEXT_LEFT, font);}
17701 layout->
clip = clip;}
17714 struct nk_vec2 scrollbar_size;
17715 struct nk_vec2 panel_padding;
17724 layout = window->
layout;
17725 style = &ctx->
style;
17728 if (!nk_panel_is_sub(layout->
type))
17733 panel_padding = nk_panel_get_padding(style, layout->
type);
17747 empty_space.x = window->
bounds.
x;
17748 empty_space.y = layout->
bounds.
y;
17749 empty_space.h = panel_padding.y;
17750 empty_space.w = window->
bounds.
w;
17754 empty_space.x = window->
bounds.
x;
17755 empty_space.y = layout->
bounds.
y;
17756 empty_space.w = panel_padding.x + layout->
border;
17757 empty_space.h = layout->
bounds.
h;
17762 empty_space.y = layout->
bounds.
y;
17763 empty_space.w = panel_padding.x + layout->
border;
17764 empty_space.h = layout->
bounds.
h;
17766 empty_space.w += scrollbar_size.x;
17771 empty_space.x = window->
bounds.
x;
17773 empty_space.w = window->
bounds.
w;
17774 empty_space.h = scrollbar_size.y;
17785 int scroll_has_scrolling;
17786 float scroll_target;
17787 float scroll_offset;
17792 if (nk_panel_is_sub(layout->
type))
17795 struct nk_window *root_window = window;
17797 while (root_panel->
parent)
17798 root_panel = root_panel->
parent;
17799 while (root_window->
parent)
17800 root_window = root_window->
parent;
17803 scroll_has_scrolling = 0;
17811 root_panel = window->
layout;
17812 while (root_panel->
parent) {
17814 root_panel = root_panel->
parent;
17817 scroll_has_scrolling =
nk_true;
17820 }
else if (!nk_panel_is_sub(layout->
type)) {
17826 }
else scroll_has_scrolling =
nk_false;
17830 nk_flags state = 0;
17831 scroll.x = layout->
bounds.
x + layout->
bounds.
w + panel_padding.x;
17833 scroll.w = scrollbar_size.x;
17836 scroll_offset = (float)*layout->
offset_y;
17837 scroll_step = scroll.h * 0.10f;
17838 scroll_inc = scroll.h * 0.01f;
17839 scroll_target = (
float)(
int)(layout->
at_y - scroll.y);
17840 scroll_offset = nk_do_scrollbarv(&state, out, scroll, scroll_has_scrolling,
17841 scroll_offset, scroll_target, scroll_step, scroll_inc,
17844 if (in && scroll_has_scrolling)
17849 nk_flags state = 0;
17853 scroll.h = scrollbar_size.y;
17855 scroll_offset = (float)*layout->
offset_x;
17856 scroll_target = (
float)(
int)(layout->
max_x - scroll.x);
17857 scroll_step = layout->
max_x * 0.05f;
17858 scroll_inc = layout->
max_x * 0.005f;
17859 scroll_offset = nk_do_scrollbarh(&state, out, scroll, scroll_has_scrolling,
17860 scroll_offset, scroll_target, scroll_step, scroll_inc,
17871 if ((!has_input && is_window_hovered) || (!is_window_hovered && !any_item_active))
17877 if (layout->
flags & NK_WINDOW_BORDER)
17879 struct nk_color border_color = nk_panel_get_border_color(style, layout->
type);
17889 layout->
border, border_color);
17898 padding_y, layout->
border, border_color);
17903 padding_y, layout->
border, border_color);
17911 scaler.
w = scrollbar_size.x;
17912 scaler.h = scrollbar_size.y;
17915 scaler.x = layout->
bounds.
x - panel_padding.x * 0.5f;
17916 else scaler.x = layout->
bounds.
x + layout->
bounds.
w + panel_padding.x;
17918 scaler.x -= scaler.w;
17927 scaler.y + scaler.h, scaler.x + scaler.w,
17928 scaler.y + scaler.h, item->
data.
color);
17931 scaler.y + scaler.h, scaler.x, scaler.y + scaler.h, item->
data.
color);
17942 if (left_mouse_down && left_mouse_click_in_scaler) {
17945 delta_x = -delta_x;
17949 if (window->
bounds.
w + delta_x >= window_size.
x) {
17950 if ((delta_x < 0) || (delta_x > 0 && in->
mouse.
pos.
x >= scaler.x)) {
17970 if (!nk_panel_is_sub(layout->
type)) {
17973 nk_command_buffer_reset(&window->
buffer);
17975 else nk_finish(ctx, window);
17997 nk_zero(&window->
edit,
sizeof(window->
edit));
18023 nk_create_page_element(
struct nk_context *ctx)
18032 elem = nk_pool_alloc(&ctx->
pool);
18034 if (!elem)
return 0;
18041 if (!elem)
return 0;
18050 nk_link_page_element_into_freelist(
struct nk_context *ctx,
18067 nk_link_page_element_into_freelist(ctx, elem);
18071 {
void *elem_end = (
void*)(elem + 1);
18073 if (elem_end == buffer_end)
18075 else nk_link_page_element_into_freelist(ctx, elem);}
18087 elem = nk_create_page_element(ctx);
18088 if (!elem)
return 0;
18098 nk_free_page_element(ctx, pe);
18110 elem = nk_create_page_element(ctx);
18111 if (!elem)
return 0;
18121 nk_free_page_element(ctx, pe);
18158 nk_hash name, nk_uint value)
18162 if (!win || !ctx)
return 0;
18164 struct nk_table *tbl = nk_create_table(ctx);
18166 if (!tbl)
return 0;
18167 nk_push_table(win, tbl);
18176 nk_find_value(
struct nk_window *win, nk_hash name)
18182 for (i = 0; i < size; ++i) {
18183 if (iter->
keys[i] == name) {
18185 return &iter->
values[i];
18203 elem = nk_create_page_element(ctx);
18204 if (!elem)
return 0;
18215 nk_free_window(ctx, win->
popup.
win);
18224 nk_remove_table(win, it);
18225 nk_free_table(ctx, it);
18234 nk_free_page_element(ctx, pe);}
18238 nk_find_window(
struct nk_context *ctx, nk_hash hash,
const char *name)
18243 NK_ASSERT(iter != iter->
next);
18244 if (iter->
name == hash) {
18254 enum nk_window_insert_location {
18260 enum nk_window_insert_location loc)
18265 if (!win || !ctx)
return;
18269 NK_ASSERT(iter != iter->
next);
18270 NK_ASSERT(iter != win);
18271 if (iter == win)
return;
18283 if (loc == NK_INSERT_BACK) {
18307 if (win == ctx->
begin || win == ctx->
end) {
18308 if (win == ctx->
begin) {
18313 if (win == ctx->
end) {
18336 struct nk_rect bounds, nk_flags flags)
18343 struct nk_rect bounds, nk_flags flags)
18347 nk_hash title_hash;
18355 NK_ASSERT(!ctx->
current &&
"if this triggers you missed a `nk_end` call");
18356 if (!ctx || ctx->
current || !title || !name)
18360 style = &ctx->
style;
18363 win = nk_find_window(ctx, title_hash, name);
18367 win = (
struct nk_window*)nk_create_window(ctx);
18369 if (!win)
return 0;
18372 nk_insert_window(ctx, win, NK_INSERT_FRONT);
18373 else nk_insert_window(ctx, win, NK_INSERT_BACK);
18378 win->
name = title_hash;
18398 NK_ASSERT(win->
seq != ctx->
seq);
18412 int inpanel, ishovered;
18420 nk_start(ctx, win);
18430 iter_bounds.
x, iter_bounds.
y, iter_bounds.
w, iter_bounds.
h) &&
18444 if (iter && inpanel && (win != ctx->
end) && !(iter->
flags & NK_WINDOW_BACKGROUND)) {
18451 iter_bounds.
x, iter_bounds.
y, iter_bounds.
w, iter_bounds.
h) &&
18463 if (!iter && ctx->
end != win) {
18464 if (!(win->
flags & NK_WINDOW_BACKGROUND)) {
18467 nk_remove_window(ctx, win);
18468 nk_insert_window(ctx, win, NK_INSERT_BACK);
18473 if (ctx->
end != win && !(win->
flags & NK_WINDOW_BACKGROUND))
18490 NK_ASSERT(ctx->
current &&
"if this triggers you forgot to call `nk_begin`");
18536 if (!ctx || !ctx->
current)
return 0;
18545 if (!ctx || !ctx->
current)
return 0;
18595 if (!ctx || !ctx->
current)
return 0;
18604 if (!ctx || !ctx->
current)
return 0;
18614 if (!ctx || !ctx->
current)
return 0;
18623 if (!ctx || !ctx->
current)
return 0;
18632 if (!ctx)
return 0;
18657 return any_hovered || any_active;
18664 nk_hash title_hash;
18667 if (!ctx)
return 0;
18671 win = nk_find_window(ctx, title_hash, name);
18672 if (!win)
return 0;
18680 nk_hash title_hash;
18683 if (!ctx)
return 1;
18687 win = nk_find_window(ctx, title_hash, name);
18688 if (!win)
return 1;
18696 nk_hash title_hash;
18699 if (!ctx)
return 1;
18703 win = nk_find_window(ctx, title_hash, name);
18704 if (!win)
return 1;
18712 nk_hash title_hash;
18715 if (!ctx)
return 0;
18719 win = nk_find_window(ctx, title_hash, name);
18720 if (!win)
return 0;
18721 return win == ctx->
active;
18728 nk_hash title_hash;
18731 return nk_find_window(ctx, title_hash, name);
18742 NK_ASSERT(ctx->
current != win &&
"You cannot close a currently active window");
18743 if (ctx->
current == win)
return;
18751 NK_ASSERT(ctx); NK_ASSERT(ctx->
current);
18752 if (!ctx || !ctx->
current)
return;
18759 NK_ASSERT(ctx); NK_ASSERT(ctx->
current);
18760 if (!ctx || !ctx->
current)
return;
18768 NK_ASSERT(ctx); NK_ASSERT(ctx->
current);
18769 if (!ctx || !ctx->
current)
return;
18779 nk_hash title_hash;
18786 win = nk_find_window(ctx, title_hash, name);
18798 if (!ctx || !cond)
return;
18806 nk_hash title_hash;
18813 win = nk_find_window(ctx, title_hash, name);
18825 if (!ctx || !cond)
return;
18833 nk_hash title_hash;
18840 win = nk_find_window(ctx, title_hash, name);
18841 if (win && ctx->
end != win) {
18842 nk_remove_window(ctx, win);
18843 nk_insert_window(ctx, win, NK_INSERT_BACK);
18929 float total_space,
int columns)
18931 float panel_padding;
18932 float panel_spacing;
18939 padding = nk_panel_get_padding(style, type);
18942 panel_padding = 2 * padding.
x;
18943 panel_spacing = (float)
NK_MAX(columns - 1, 0) * spacing.x;
18944 panel_space = total_space - panel_padding - panel_spacing;
18945 return panel_space;
18950 float height,
int cols)
18967 style = &ctx->
style;
18985 layout->
row.
height = height + item_spacing.y;
18990 background.x = win->
bounds.
x;
18991 background.w = win->
bounds.
w;
18992 background.y = layout->
at_y - 1.0f;
18993 background.h = layout->
row.
height + 1.0f;
19000 float height,
int cols,
int width)
19011 nk_panel_layout(ctx, win, height, cols);
19027 NK_ASSERT(pixel_width);
19047 float row_height,
int cols)
19060 nk_panel_layout(ctx, win, row_height, cols);
19091 float ratio = ratio_or_width;
19092 if ((ratio + layout->
row.
filled) > 1.0f)
return;
19122 float height,
int cols,
const float *ratio)
19137 nk_panel_layout(ctx, win, height, cols);
19142 for (i = 0; i < cols; ++i) {
19143 if (ratio[i] < 0.0f)
19145 else r += ratio[i];
19149 layout->
row.
item_width = (r > 0 && n_undef > 0) ? (r / (
float)n_undef):0;
19174 nk_panel_layout(ctx, win, height, 1);
19258 int variable_count = 0;
19259 int min_variable_count = 0;
19260 float min_fixed_width = 0.0f;
19261 float total_fixed_width = 0.0f;
19262 float max_variable_width = 0.0f;
19276 if (width >= 0.0f) {
19277 total_fixed_width += width;
19278 min_fixed_width += width;
19279 }
else if (width < -1.0f) {
19281 total_fixed_width += width;
19282 max_variable_width =
NK_MAX(max_variable_width, width);
19285 min_variable_count++;
19289 if (variable_count) {
19290 float space = nk_layout_row_calculate_usable_space(&ctx->
style, layout->
type,
19292 float var_width = (
NK_MAX(space-min_fixed_width,0.0f)) / (
float)variable_count;
19293 int enough_space = var_width >= max_variable_width;
19295 var_width = (
NK_MAX(space-total_fixed_width,0)) / (
float)min_variable_count;
19298 *width = (*width >= 0.0f)? *width: (*width < -1.0f && !enough_space)? -(*width): var_width;
19305 float height,
int widget_count)
19318 nk_panel_layout(ctx, win, height, widget_count);
19379 ret.x = layout->
clip.
x;
19380 ret.y = layout->
clip.
y;
19381 ret.w = layout->
clip.
w;
19393 NK_ASSERT(ctx->current);
19394 NK_ASSERT(ctx->current->layout);
19395 win = ctx->current;
19410 NK_ASSERT(ctx->current);
19411 NK_ASSERT(ctx->current->layout);
19412 win = ctx->current;
19427 NK_ASSERT(ctx->current);
19428 NK_ASSERT(ctx->current->layout);
19429 win = ctx->current;
19444 NK_ASSERT(ctx->current);
19445 NK_ASSERT(ctx->current->layout);
19446 win = ctx->current;
19459 const float row_height = layout->
row.
height - spacing.
y;
19460 nk_panel_layout(ctx, win, row_height, layout->
row.
columns);
19473 float item_offset = 0;
19474 float item_width = 0;
19475 float item_spacing = 0;
19476 float panel_space = 0;
19486 style = &ctx->
style;
19490 padding = nk_panel_get_padding(style, layout->
type);
19491 panel_space = nk_layout_row_calculate_usable_space(&ctx->
style, layout->
type,
19499 item_offset = (
float)layout->
row.
index * item_width;
19500 item_spacing = (float)layout->
row.
index * spacing.x;
19531 item_spacing = (
float)layout->
row.
index * spacing.x;
19532 item_width = (ratio * panel_space);
19543 item_offset = (float)layout->
row.
index * item_width;
19544 item_spacing = (
float)layout->
row.
index * spacing.x;
19550 item_spacing = (float)layout->
row.
index * spacing.x;
19557 if (((bounds->
x + bounds->
w) > layout->
max_x) && modify)
19558 layout->
max_x = (bounds->
x + bounds->
w);
19567 item_spacing = (float)layout->
row.
index * spacing.x;
19578 item_spacing = (float)layout->
row.
index * spacing.x;
19581 default: NK_ASSERT(0);
break;
19585 bounds->
w = item_width;
19588 bounds->
x = layout->
at_x + item_offset + item_spacing + padding.
x;
19589 if (((bounds->
x + bounds->
w) > layout->
max_x) && modify)
19590 layout->
max_x = bounds->
x + bounds->
w;
19610 nk_panel_alloc_row(ctx, win);
19613 nk_layout_widget_space(bounds, ctx, win,
nk_true);
19639 nk_layout_widget_space(bounds, ctx, win,
nk_false);
19657 struct nk_rect header = {0,0,0,0};
19658 struct nk_rect sym = {0,0,0,0};
19674 style = &ctx->
style;
19679 widget_state =
nk_widget(&header, ctx);
19684 text.background =
nk_rgba(0,0,0,0);
19686 text.background = background->
data.
color;
19717 button, 0, style->
font);
19721 sym.
x = sym.
x + sym.
w + 4 * item_spacing.x;
19728 header.
w =
NK_MAX(header.
w, sym.
w + item_spacing.x);
19729 label.
x = sym.
x + sym.
w + item_spacing.x;
19731 label.
w = header.
w - (sym.
w + item_spacing.y + style->
tab.
indent);
19735 nk_widget_text(out, label, title,
nk_strlen(title), &text,
19751 const char *hash,
int len,
int line)
19755 nk_hash tree_hash = 0;
19756 nk_uint *state = 0;
19761 tree_hash =
nk_murmur_hash(title, (
int)title_len, (nk_hash)line);
19763 state = nk_find_value(win, tree_hash);
19765 state = nk_add_value(ctx, win, tree_hash, 0);
19766 *state = initial_state;
19774 {
return nk_tree_state_base(ctx, type, 0, title, state);}
19779 {
return nk_tree_state_base(ctx, type, &img, title, state);}
19804 const char *hash,
int len,
int line)
19805 {
return nk_tree_base(ctx, type, 0, title, initial_state, hash, len, line);}
19810 const char *hash,
int len,
int seed)
19811 {
return nk_tree_base(ctx, type, &img, title, initial_state, hash, len, seed);}
19830 nk_layout_peek(&bounds, ctx);
19843 nk_layout_peek(&bounds, ctx);
19856 nk_layout_peek(&bounds, ctx);
19869 nk_layout_peek(&bounds, ctx);
19882 nk_layout_peek(&bounds, ctx);
19896 nk_layout_peek(&bounds, ctx);
19912 nk_layout_peek(&bounds, ctx);
19928 nk_layout_peek(&bounds, ctx);
19948 nk_panel_alloc_space(bounds, ctx);
19963 bounds->
x = (float)((
int)bounds->
x);
19964 bounds->
y = (float)((
int)bounds->
y);
19965 bounds->
w = (float)((
int)bounds->
w);
19966 bounds->
h = (float)((
int)bounds->
h);
19968 c.x = (float)((
int)c.x);
19969 c.y = (float)((
int)c.y);
19970 c.w = (float)((
int)c.w);
19971 c.h = (float)((
int)c.h);
19973 if (!
NK_INTERSECT(c.x, c.y, c.w, c.h, bounds->
x, bounds->
y, bounds->
w, bounds->
h))
19975 if (!
NK_CONTAINS(bounds->
x, bounds->
y, bounds->
w, bounds->
h, c.x, c.y, c.w, c.h))
19989 struct nk_vec2 panel_padding;
19998 style = &ctx->
style;
20002 panel_padding = nk_panel_get_padding(style, layout->
type);
20004 bounds->
w += panel_padding.x;
20005 bounds->
x -= panel_padding.x;
20006 }
else bounds->
x -= item_padding.
x;
20009 bounds->
w += panel_padding.x;
20010 else bounds->
w += item_padding.
x;
20025 int i, index, rows;
20039 for (i = 0; i < rows; ++i)
20040 nk_panel_alloc_row(ctx, win);
20047 for (i = 0; i < cols; ++i)
20048 nk_panel_alloc_space(&none, ctx);
20060 nk_flags alignment,
struct nk_color color)
20075 style = &ctx->
style;
20076 nk_panel_alloc_space(&bounds, ctx);
20083 nk_widget_text(&win->
buffer, bounds, str, len, &text, alignment, style->
font);
20103 style = &ctx->
style;
20104 nk_panel_alloc_space(&bounds, ctx);
20111 nk_widget_text_wrap(&win->
buffer, bounds, str, len, &text, style->
font);
20114 #ifdef NK_INCLUDE_STANDARD_VARARGS
20116 nk_labelf_colored(
struct nk_context *ctx, nk_flags flags,
20117 struct nk_color color,
const char *fmt, ...)
20121 va_start(args, fmt);
20122 nk_strfmt(buf,
NK_LEN(buf), fmt, args);
20129 const char *fmt, ...)
20133 va_start(args, fmt);
20134 nk_strfmt(buf,
NK_LEN(buf), fmt, args);
20140 nk_labelf(
struct nk_context *ctx, nk_flags flags,
const char *fmt, ...)
20144 va_start(args, fmt);
20145 nk_strfmt(buf,
NK_LEN(buf), fmt, args);
20151 nk_labelf_wrap(
struct nk_context *ctx,
const char *fmt,...)
20155 va_start(args, fmt);
20156 nk_strfmt(buf,
NK_LEN(buf), fmt, args);
20162 nk_value_bool(
struct nk_context *ctx,
const char *prefix,
int value)
20163 {nk_labelf(ctx,
NK_TEXT_LEFT,
"%s: %s", prefix, ((value) ?
"true":
"false"));}
20166 nk_value_int(
struct nk_context *ctx,
const char *prefix,
int value)
20167 {nk_labelf(ctx,
NK_TEXT_LEFT,
"%s: %d", prefix, value);}
20170 nk_value_uint(
struct nk_context *ctx,
const char *prefix,
unsigned int value)
20171 {nk_labelf(ctx,
NK_TEXT_LEFT,
"%s: %u", prefix, value);}
20174 nk_value_float(
struct nk_context *ctx,
const char *prefix,
float value)
20176 double double_value = (double)value;
20177 nk_labelf(ctx,
NK_TEXT_LEFT,
"%s: %.3f", prefix, double_value);
20182 {nk_labelf(ctx,
NK_TEXT_LEFT,
"%s: (%d, %d, %d, %d)", p, c.
r, c.
g, c.
b, c.
a);}
20188 nk_labelf(ctx,
NK_TEXT_LEFT,
"%s: (%.2f, %.2f, %.2f, %.2f)",
20189 p, c[0], c[1], c[2], c[3]);
20193 nk_value_color_hex(
struct nk_context *ctx,
const char *prefix,
struct nk_color color)
20266 struct nk_config_stack_button_behavior *button_stack;
20267 struct nk_config_stack_button_behavior_element *element;
20270 if (!ctx)
return 0;
20273 NK_ASSERT(button_stack->head < (
int)
NK_LEN(button_stack->elements));
20274 if (button_stack->head >= (
int)
NK_LEN(button_stack->elements))
20277 element = &button_stack->elements[button_stack->head++];
20287 struct nk_config_stack_button_behavior *button_stack;
20288 struct nk_config_stack_button_behavior_element *element;
20291 if (!ctx)
return 0;
20294 NK_ASSERT(button_stack->head > 0);
20295 if (button_stack->head < 1)
20298 element = &button_stack->elements[--button_stack->head];
20299 *element->address = element->old_value;
20324 if (!state)
return 0;
20335 if (!ctx)
return 0;
20369 if (!state)
return 0;
20402 if (!state)
return 0;
20412 if (!ctx)
return 0;
20437 if (!state)
return 0;
20447 if (!ctx)
return 0;
20454 const char *text,
int len, nk_flags align)
20473 if (!state)
return 0;
20482 const char* text,
int len, nk_flags align)
20485 if (!ctx)
return 0;
20490 const char *label, nk_flags align)
20495 const char *title, nk_flags align)
20501 int len, nk_flags align)
20520 if (!state)
return 0;
20529 const char *text,
int len, nk_flags align)
20534 const char *label, nk_flags align)
20539 const char *label, nk_flags text_alignment)
20549 nk_flags align,
int *value)
20568 style = &ctx->
style;
20571 if (!state)
return 0;
20579 const char *str,
int len, nk_flags align,
int *value)
20598 style = &ctx->
style;
20601 if (!state)
return 0;
20604 str, len, align, value, &img, &style->
selectable, in, style->
font);
20608 nk_flags align,
int value)
20615 const char *str, nk_flags align,
int *value)
20622 const char *str, nk_flags align,
int value)
20626 const char *str,
int len, nk_flags align,
int value)
20652 style = &ctx->
style;
20656 if (!state)
return active;
20659 text, len, NK_TOGGLE_CHECK, &style->
checkbox, in, style->
font);
20665 unsigned int flags,
unsigned int value)
20670 if (!ctx || !text)
return flags;
20671 old_active = (
int)((flags & value) &
value);
20674 else flags &= ~value;
20685 if (!ctx || !text || !active)
return 0;
20688 return old_val != *active;
20693 unsigned int *flags,
unsigned int value)
20699 if (!ctx || !text || !flags)
return 0;
20701 active = (
int)((*flags & value) &
value);
20703 if (active) *flags |=
value;
20704 else *flags &= ~value;
20714 unsigned int flags,
unsigned int value)
20721 unsigned int *flags,
unsigned int value)
20747 style = &ctx->
style;
20751 if (!state)
return state;
20754 text, len, NK_TOGGLE_OPTION, &style->
option, in, style->
font);
20765 if (!ctx || !text || !active)
return 0;
20766 old_value = *active;
20768 return old_value != *active;
20806 style = &ctx->
style;
20810 if (!state)
return ret;
20813 old_value = *value;
20815 old_value, max_value, value_step, &style->
slider, in, style->
font);
20816 return (old_value > *value || old_value < *value);
20828 float value = (float)val;
20837 float value = (float)*val;
20838 ret =
nk_slider_float(ctx, (
float)min, &value, (
float)max, (
float)step);
20868 style = &ctx->
style;
20871 if (!state)
return 0;
20876 *cur, max, is_modifyable, &style->
progress, in);
20877 return (*cur != old_value);
20881 {
nk_progress(ctx, &cur, max, modifyable);
return cur;}
20896 if (!ctx || !ctx->
current)
return;
20902 if (flags & NK_EDIT_ALWAYS_INSERT_MODE)
20912 if (!ctx || !ctx->
current)
return;
20931 if (!ctx || !memory || !len)
20938 nk_textedit_clear_state(&ctx->
text_edit, (flags & NK_EDIT_MULTILINE)?
20959 *len =
NK_MIN(*len, max-1);
20988 nk_flags ret_flags = 0;
20989 unsigned char prev_state;
21001 style = &ctx->
style;
21003 if (!state)
return state;
21009 if (flags & NK_EDIT_NO_CURSOR)
21015 if (flags & NK_EDIT_CLIPBOARD)
21020 prev_state = (
unsigned char)edit->
active;
21021 in = (flags & NK_EDIT_READ_ONLY) ? 0: in;
21023 filter, edit, &style->
edit, in, style->
font);
21031 }
else if (prev_state && !edit->
active) {
21055 nk_property_variant_int(int value, int min_value, int max_value, int step)
21057 struct nk_property_variant result;
21058 result.kind = NK_PROPERTY_INT;
21059 result.value.i =
value;
21060 result.min_value.i = min_value;
21061 result.max_value.i = max_value;
21062 result.step.i = step;
21067 nk_property_variant_float(float value, float min_value, float max_value, float step)
21069 struct nk_property_variant result;
21070 result.kind = NK_PROPERTY_FLOAT;
21071 result.value.f =
value;
21072 result.min_value.f = min_value;
21073 result.max_value.f = max_value;
21074 result.step.f = step;
21079 nk_property_variant_double(double value, double min_value, double max_value,
21082 struct nk_property_variant result;
21083 result.kind = NK_PROPERTY_DOUBLE;
21084 result.value.d =
value;
21085 result.min_value.d = min_value;
21086 result.max_value.d = max_value;
21087 result.step.d = step;
21092 nk_property(
struct nk_context *ctx,
const char *name,
struct nk_property_variant *variant,
21093 float inc_per_pixel,
const enum nk_property_filter filter)
21108 int *select_begin = 0;
21109 int *select_end = 0;
21113 int dummy_state = NK_PROPERTY_DEFAULT;
21114 int dummy_length = 0;
21115 int dummy_cursor = 0;
21116 int dummy_select_begin = 0;
21117 int dummy_select_end = 0;
21127 style = &ctx->
style;
21133 if (name[0] ==
'#') {
21147 buffer = dummy_buffer;
21148 len = &dummy_length;
21149 cursor = &dummy_cursor;
21150 state = &dummy_state;
21151 select_begin = &dummy_select_begin;
21152 select_end = &dummy_select_end;
21156 old_state = *state;
21159 variant, inc_per_pixel, buffer, len, state, cursor, select_begin,
21163 if (in && *state != NK_PROPERTY_DEFAULT && !win->
property.
active) {
21173 if (*state == NK_PROPERTY_DRAG) {
21180 if (*state == NK_PROPERTY_DEFAULT && old_state != NK_PROPERTY_DEFAULT) {
21181 if (old_state == NK_PROPERTY_DRAG) {
21192 int min,
int *val,
int max,
int step,
float inc_per_pixel)
21194 struct nk_property_variant variant;
21199 if (!ctx || !ctx->
current || !name || !val)
return;
21200 variant = nk_property_variant_int(*val, min, max, step);
21201 nk_property(ctx, name, &variant, inc_per_pixel, NK_FILTER_INT);
21202 *val = variant.value.i;
21207 float min,
float *val,
float max,
float step,
float inc_per_pixel)
21209 struct nk_property_variant variant;
21214 if (!ctx || !ctx->
current || !name || !val)
return;
21215 variant = nk_property_variant_float(*val, min, max, step);
21216 nk_property(ctx, name, &variant, inc_per_pixel, NK_FILTER_FLOAT);
21217 *val = variant.value.f;
21222 double min,
double *val,
double max,
double step,
float inc_per_pixel)
21224 struct nk_property_variant variant;
21229 if (!ctx || !ctx->
current || !name || !val)
return;
21230 variant = nk_property_variant_double(*val, min, max, step);
21231 nk_property(ctx, name, &variant, inc_per_pixel, NK_FILTER_FLOAT);
21232 *val = variant.value.d;
21237 int max,
int step,
float inc_per_pixel)
21239 struct nk_property_variant variant;
21243 if (!ctx || !ctx->
current || !name)
return val;
21244 variant = nk_property_variant_int(val, min, max, step);
21245 nk_property(ctx, name, &variant, inc_per_pixel, NK_FILTER_INT);
21246 val = variant.value.i;
21252 float val,
float max,
float step,
float inc_per_pixel)
21254 struct nk_property_variant variant;
21258 if (!ctx || !ctx->
current || !name)
return val;
21259 variant = nk_property_variant_float(val, min, max, step);
21260 nk_property(ctx, name, &variant, inc_per_pixel, NK_FILTER_FLOAT);
21261 val = variant.value.f;
21267 double val,
double max,
double step,
float inc_per_pixel)
21269 struct nk_property_variant variant;
21273 if (!ctx || !ctx->
current || !name)
return val;
21274 variant = nk_property_variant_double(val, min, max, step);
21275 nk_property(ctx, name, &variant, inc_per_pixel, NK_FILTER_FLOAT);
21276 val = variant.value.d;
21305 config = &ctx->
style;
21308 if (!state)
return 0;
21330 int count,
float min_value,
float max_value)
21338 struct nk_rect bounds = {0, 0, 0, 0};
21347 nk_zero(chart,
sizeof(*chart));
21352 config = &ctx->
style;
21354 style = &config->
chart;
21357 nk_zero(chart,
sizeof(*chart));
21371 slot->
min =
NK_MIN(min_value, max_value);
21372 slot->
max =
NK_MAX(min_value, max_value);
21389 int count,
float min_value,
float max_value)
21395 int count,
float min_value,
float max_value)
21411 slot->
min =
NK_MIN(min_value, max_value);
21412 slot->
max =
NK_MAX(min_value, max_value);
21418 int count,
float min_value,
float max_value)
21423 struct nk_chart *g,
float value,
int slot)
21440 ratio = (value - g->
slots[slot].
min) / range;
21445 g->
slots[slot].
last.
y = (g->
y + g->
h) - ratio * (
float)g->
h;
21449 bounds.
w = bounds.
h = 4;
21466 cur.x = g->
x + (float)(step * (
float)g->
slots[slot].
index);
21467 cur.y = (g->
y + g->
h) - (ratio * (
float)g->
h);
21470 bounds.
x = cur.x - 3;
21471 bounds.
y = cur.y - 3;
21472 bounds.
w = bounds.
h = 6;
21494 struct nk_chart *chart,
float value,
int slot)
21503 struct nk_rect item = {0,0,0,0};
21509 float padding = (float)(chart->
slots[slot].
count-1);
21510 item.
w = (chart->
w - padding) / (
float)(chart->
slots[slot].
count);
21518 item.
y = (chart->
y + chart->
h) - chart->
h * ratio;
21521 item.
y = chart->
y + (chart->
h *
NK_ABS(ratio)) - item.
h;
21523 item.
x = chart->
x + ((float)chart->
slots[slot].
index * item.
w);
21548 NK_ASSERT(slot < ctx->
current->layout->chart.slot);
21556 flags = nk_chart_push_line(ctx, win, &win->
layout->
chart, value, slot);
break;
21558 flags = nk_chart_push_column(ctx, win, &win->
layout->
chart, value, slot);
break;
21583 NK_MEMSET(chart, 0,
sizeof(*chart));
21589 int count,
int offset)
21597 if (!ctx || !values || !count)
return;
21599 min_value = values[offset];
21600 max_value = values[offset];
21601 for (i = 0; i < count; ++i) {
21602 min_value =
NK_MIN(values[i + offset], min_value);
21603 max_value =
NK_MAX(values[i + offset], max_value);
21606 for (i = 0; i < count; ++i)
21613 float(*value_getter)(
void* user,
int index),
int count,
int offset)
21620 NK_ASSERT(value_getter);
21621 if (!ctx || !value_getter || !count)
return;
21623 max_value = min_value = value_getter(userdata, offset);
21624 for (i = 0; i < count; ++i) {
21625 float value = value_getter(userdata, i + offset);
21626 min_value =
NK_MIN(value, min_value);
21627 max_value =
NK_MAX(value, max_value);
21630 for (i = 0; i < count; ++i)
21642 nk_uint *x_offset, nk_uint *y_offset,
const char *title, nk_flags flags)
21649 nk_panel_alloc_space(&bounds, ctx);
21659 nk_zero(&panel,
sizeof(panel));
21660 panel.bounds = bounds;
21661 panel.flags = flags;
21662 panel.scrollbar.
x = *x_offset;
21663 panel.scrollbar.y = *y_offset;
21664 panel.buffer = win->
buffer;
21665 panel.layout = (
struct nk_panel*)nk_create_panel(ctx);
21669 win->
buffer = panel.buffer;
21671 panel.layout->offset_x = x_offset;
21672 panel.layout->offset_y = y_offset;
21673 panel.layout->parent = win->
layout;
21674 win->
layout = panel.layout;
21680 nk_flags f = panel.layout->flags;
21699 struct nk_vec2 panel_padding;
21718 pan.bounds.x = g->
bounds.
x - panel_padding.x;
21719 pan.bounds.w = g->
bounds.
w + 2 * panel_padding.x;
21721 if (g->
flags & NK_WINDOW_BORDER) {
21722 pan.bounds.x -= g->
border;
21723 pan.bounds.y -= g->
border;
21724 pan.bounds.w += 2*g->
border;
21725 pan.bounds.h += 2*g->
border;
21733 pan.flags = g->
flags;
21734 pan.buffer = win->
buffer;
21740 nk_unify(&clip, &parent->
clip, pan.bounds.
x, pan.bounds.y,
21741 pan.bounds.x + pan.bounds.w, pan.bounds.y + pan.bounds.h + panel_padding.x);
21745 win->
buffer = pan.buffer;
21755 struct nk_scroll *scroll,
const char *title, nk_flags flags)
21762 nk_hash title_hash;
21778 x_offset = nk_find_value(win, title_hash);
21780 x_offset = nk_add_value(ctx, win, title_hash, 0);
21781 y_offset = nk_add_value(ctx, win, title_hash+1, 0);
21783 NK_ASSERT(x_offset);
21784 NK_ASSERT(y_offset);
21785 if (!x_offset || !y_offset)
return 0;
21786 *x_offset = *y_offset = 0;
21787 }
else y_offset = nk_find_value(win, title_hash+1);
21797 const char *title, nk_flags flags,
int row_height,
int row_count)
21800 nk_hash title_hash;
21813 if (!ctx || !view || !title)
return 0;
21816 style = &ctx->
style;
21818 row_height +=
NK_MAX(0, (
int)item_spacing.y);
21823 x_offset = nk_find_value(win, title_hash);
21825 x_offset = nk_add_value(ctx, win, title_hash, 0);
21826 y_offset = nk_add_value(ctx, win, title_hash+1, 0);
21828 NK_ASSERT(x_offset);
21829 NK_ASSERT(y_offset);
21830 if (!x_offset || !y_offset)
return 0;
21831 *x_offset = *y_offset = 0;
21832 }
else y_offset = nk_find_value(win, title_hash+1);
21857 NK_ASSERT(view->
ctx);
21859 if (!view || !view->
ctx)
return;
21876 const char *title, nk_flags flags,
struct nk_rect rect)
21883 nk_hash title_hash;
21902 popup = (
struct nk_window*)nk_create_window(ctx);
21912 nk_zero(popup,
sizeof(*popup));
21935 nk_start_popup(ctx, win);
21965 nk_free_panel(ctx, popup->
layout);
21995 popup = (
struct nk_window*)nk_create_window(ctx);
22002 int pressed, in_body, in_header;
22006 if (pressed && (!in_body || in_header))
22029 NK_ASSERT(popup->
layout);
22031 nk_start_popup(ctx, win);
22036 nk_panel_begin(ctx, 0, panel_type);
22057 if (!ctx || !ctx->
current)
return;
22060 NK_ASSERT(popup->
parent);
22078 if (!popup->
parent)
return;
22093 nk_finish_popup(ctx, win);
22123 bounds.
h = nk_null_rect.h;
22140 if (!ctx || !ctx->
current)
return;
22164 style = &ctx->
style;
22171 text_width += (4 * padding.x);
22172 text_height = (style->
font->
height + 2 * padding.y);
22188 struct nk_rect trigger_bounds)
22195 int is_clicked = 0;
22215 if ((is_clicked && is_open && !is_active) || (!is_open && !is_active && !is_clicked))
22244 nk_flags alignment)
22260 style = &ctx->
style;
22278 const char *text,
int len, nk_flags align)
22294 style = &ctx->
style;
22308 const char *label, nk_flags align)
22313 const char *text,
int len, nk_flags align)
22329 style = &ctx->
style;
22343 const char *text, nk_flags align)
22363 if (!ctx || !ctx->
current)
return;
22367 NK_ASSERT(popup->
parent);
22375 struct nk_rect body = {0,0,0,0};
22385 if (pressed && in_body)
22424 if ((is_clicked && is_open && !is_active) || (is_open && !is_active) ||
22425 (!is_open && !is_active && !is_clicked))
return 0;
22426 if (!nk_nonblock_begin(ctx, 0, body,
22449 NK_ASSERT(selected);
22456 style = &ctx->
style;
22477 text.background =
nk_rgba(0,0,0,0);
22480 text.background = background->
data.
color;
22493 else if (is_clicked)
22501 button.h = button.w;
22514 nk_widget_text(&win->
buffer, label, selected, len, &text,
22521 return nk_combo_begin(ctx, win, size, is_clicked, header);
22546 style = &ctx->
style;
22576 else if (is_clicked)
22584 button.h = button.w;
22602 return nk_combo_begin(ctx, win, size, is_clicked, header);
22626 style = &ctx->
style;
22648 sym_background =
nk_rgba(0,0,0,0);
22651 sym_background = background->
data.
color;
22656 struct nk_rect bounds = {0,0,0,0};
22663 else if (is_clicked)
22671 button.h = button.w;
22683 nk_draw_symbol(&win->
buffer, symbol, bounds, sym_background, symbol_color,
22684 1.0f, style->
font);
22690 return nk_combo_begin(ctx, win, size, is_clicked, header);
22715 style = &ctx->
style;
22738 text.background =
nk_rgba(0,0,0,0);
22741 text.background = background->
data.
color;
22754 else if (is_clicked)
22762 button.h = button.w;
22776 nk_draw_symbol(&win->
buffer, symbol, image, text.background, symbol_color,
22777 1.0f, style->
font);
22787 return nk_combo_begin(ctx, win, size, is_clicked, header);
22809 style = &ctx->
style;
22832 struct nk_rect bounds = {0,0,0,0};
22839 else if (is_clicked)
22847 button.h = button.w;
22865 return nk_combo_begin(ctx, win, size, is_clicked, header);
22889 style = &ctx->
style;
22909 text.background =
nk_rgba(0,0,0,0);
22912 text.background = background->
data.
color;
22925 else if (is_clicked)
22933 button.h = button.w;
22957 return nk_combo_begin(ctx, win, size, is_clicked, header);
22975 int len, nk_flags alignment)
22979 const char *text, nk_flags alignment)
22983 const char *text,
int len, nk_flags alignment)
22987 const char *label, nk_flags alignment)
22998 int selected,
int item_height,
struct nk_vec2 size)
23003 struct nk_vec2 window_padding;
23008 if (!ctx || !items ||!count)
23013 max_height = count * item_height + count * (
int)item_spacing.y;
23014 max_height += (
int)item_spacing.y * 2 + (
int)window_padding.y * 2;
23015 size.
y =
NK_MIN(size.
y, (
float)max_height);
23018 for (i = 0; i < count; ++i) {
23029 int separator,
int selected,
int count,
int item_height,
struct nk_vec2 size)
23034 struct nk_vec2 window_padding;
23035 const char *current_item;
23040 NK_ASSERT(items_separated_by_separator);
23041 if (!ctx || !items_separated_by_separator)
23047 max_height = count * item_height + count * (
int)item_spacing.y;
23048 max_height += (
int)item_spacing.y * 2 + (
int)window_padding.y * 2;
23049 size.
y =
NK_MIN(size.
y, (
float)max_height);
23052 current_item = items_separated_by_separator;
23053 for (i = 0; i < count; ++i) {
23054 iter = current_item;
23055 while (*iter && *iter != separator) iter++;
23056 length = (
int)(iter - current_item);
23057 if (i == selected)
break;
23058 current_item = iter + 1;
23062 current_item = items_separated_by_separator;
23064 for (i = 0; i < count; ++i) {
23065 iter = current_item;
23066 while (*iter && *iter != separator) iter++;
23067 length = (
int)(iter - current_item);
23070 current_item = current_item + length + 1;
23079 int selected,
int count,
int item_height,
struct nk_vec2 size)
23080 {
return nk_combo_separator(ctx, items_separated_by_zeros,
'\0', selected, count, item_height, size);}
23084 void *userdata,
int selected,
int count,
int item_height,
struct nk_vec2 size)
23089 struct nk_vec2 window_padding;
23093 NK_ASSERT(item_getter);
23094 if (!ctx || !item_getter)
23100 max_height = count * item_height + count * (
int)item_spacing.y;
23101 max_height += (
int)item_spacing.y * 2 + (
int)window_padding.y * 2;
23102 size.
y =
NK_MIN(size.
y, (
float)max_height);
23104 item_getter(userdata, selected, &item);
23107 for (i = 0; i < count; ++i) {
23108 item_getter(userdata, i, &item);
23118 int *selected,
int item_height,
struct nk_vec2 size)
23119 {*selected =
nk_combo(ctx, items, count, *selected, item_height, size);}
23122 int *selected,
int count,
int item_height,
struct nk_vec2 size)
23123 {*selected =
nk_combo_string(ctx, items_separated_by_zeros, *selected, count, item_height, size);}
23126 int separator,
int *selected,
int count,
int item_height,
struct nk_vec2 size)
23128 *selected, count, item_height, size);}
23131 void(*item_getter)(
void* data,
int id,
const char **out_text),
23132 void *userdata,
int *selected,
int count,
int item_height,
struct nk_vec2 size)
23133 {*selected =
nk_combo_callback(ctx, item_getter, userdata, *selected, count, item_height, size);}
23144 const char *
id,
int is_clicked,
struct nk_rect header,
struct nk_vec2 size)
23160 body.
y = header.
y + header.
h;
23166 if ((is_clicked && is_open && !is_active) || (is_open && !is_active) ||
23167 (!is_open && !is_active && !is_clicked))
return 0;
23178 nk_flags align,
struct nk_vec2 size)
23194 if (!state)
return 0;
23199 return nk_menu_begin(ctx, win, title, is_clicked, header, size);
23203 const char *text, nk_flags align,
struct nk_vec2 size)
23224 if (!state)
return 0;
23229 return nk_menu_begin(ctx, win,
id, is_clicked, header, size);
23250 if (!state)
return 0;
23255 return nk_menu_begin(ctx, win,
id, is_clicked, header, size);
23276 if (!state)
return 0;
23282 return nk_menu_begin(ctx, win, title, is_clicked, header, size);
23286 const char *title, nk_flags align,
struct nk_image img,
struct nk_vec2 size)
23307 if (!state)
return 0;
23313 return nk_menu_begin(ctx, win, title, is_clicked, header, size);
23327 const char *label, nk_flags align)
23331 const char *text,
int len, nk_flags align)
23335 const char *text,
int len, nk_flags align)
23339 const char *label, nk_flags align)
Definition: nuklear.h:1901
unsigned short r
Definition: nuklear.h:2943
struct nk_vec2 padding
Definition: nuklear.h:3506
Definition: nuklear.h:3006
Definition: nuklear.h:2026
NK_API struct nk_color nk_rgb_iv(const int *rgb)
struct nk_command header
Definition: nuklear.h:2856
Definition: nuklear.h:689
short cx
Definition: nuklear.h:2942
NK_API int nk_menu_item_text(struct nk_context *, const char *, int, nk_flags align)
struct nk_style_item hover
Definition: nuklear.h:3456
nk_chart_event
Definition: nuklear.h:472
struct nk_vec2 padding
Definition: nuklear.h:3412
float preferred_x
Definition: nuklear.h:2740
struct nk_style_item hover_active
Definition: nuklear.h:3328
NK_API int nk_window_has_focus(const struct nk_context *)
NK_API int nk_menu_item_symbol_text(struct nk_context *, enum nk_symbol_type, const char *, int, nk_flags alignment)
Definition: nuklear.h:3725
struct nk_style_button dec_button
Definition: nuklear.h:3510
NK_API struct nk_rect nk_rectv(const float *xywh)
nk_handle userdata
Definition: nuklear.h:3415
Definition: nuklear.h:1889
#define NK_CONFIG_STACK(type, size)
Definition: nuklear.h:3929
struct nk_style_item cursor_hover
Definition: nuklear.h:3299
struct nk_command header
Definition: nuklear.h:2909
NK_API int nk_input_mouse_clicked(const struct nk_input *, enum nk_buttons, struct nk_rect)
struct nk_pool pool
Definition: nuklear.h:4035
struct nk_style_item active
Definition: nuklear.h:3359
NK_API int nk_select_text(struct nk_context *, const char *, int, nk_flags align, int value)
NK_API int nk_tree_state_image_push(struct nk_context *, enum nk_tree_type, struct nk_image, const char *title, enum nk_collapse_states *state)
unsigned int scrolled
Definition: nuklear.h:3859
NK_API void nk_window_set_position(struct nk_context *, struct nk_vec2 pos)
NK_API struct nk_color nk_rgba_bv(const nk_byte *rgba)
float menu_border
Definition: nuklear.h:3630
NK_API int nk_contextual_item_image_text(struct nk_context *, struct nk_image, const char *, int len, nk_flags alignment)
NK_API void nk_textedit_select_all(struct nk_text_edit *)
Definition: nuklear.h:2940
nk_convert_result
Definition: nuklear.h:970
NK_API int nk_button_symbol_label_styled(struct nk_context *ctx, const struct nk_style_button *style, enum nk_symbol_type symbol, const char *title, nk_flags align)
NK_API int nk_contextual_begin(struct nk_context *, nk_flags, struct nk_vec2, struct nk_rect trigger_bounds)
struct nk_vec2 last
Definition: nuklear.h:3710
struct nk_color text_hover
Definition: nuklear.h:3333
Definition: nuklear.h:3704
Definition: nuklear.h:2931
void * memory
Definition: nuklear.h:2537
struct nk_style_item cursor_normal
Definition: nuklear.h:3298
NK_API void nk_color_hex_rgb(char *output, struct nk_color)
Definition: nuklear.h:2040
float border
Definition: nuklear.h:3769
NK_API struct nk_rect nk_get_null_rect(void)
nk_buffer_allocation_type
Definition: nuklear.h:2550
NK_API int nk_begin(struct nk_context *ctx, const char *title, struct nk_rect bounds, nk_flags flags)
void *(* nk_plugin_alloc)(nk_handle, void *old, nk_size)
Definition: nuklear.h:478
struct nk_color color
Definition: nuklear.h:2945
#define NK_STORAGE
Definition: nuklear.h:287
nk_handle userdata
Definition: nuklear.h:3389
nk_widget_states
Definition: nuklear.h:1714
void(* nk_plugin_paste)(nk_handle, struct nk_text_edit *)
Definition: nuklear.h:481
Definition: nuklear.h:1184
float tooltip_border
Definition: nuklear.h:3632
float max_x
Definition: nuklear.h:3766
#define NK_INT32
Definition: nuklear.h:352
NK_API int nk_contextual_item_symbol_text(struct nk_context *, enum nk_symbol_type, const char *, int, nk_flags alignment)
NK_API int nk_filter_default(const struct nk_text_edit *, nk_rune unicode)
unsigned int page_count
Definition: nuklear.h:3996
nk_size allocated
Definition: nuklear.h:2573
unsigned short w
Definition: nuklear.h:2892
NK_API void nk_stroke_circle(struct nk_command_buffer *, struct nk_rect, float line_thickness, struct nk_color)
NK_API struct nk_vec2 nk_vec2i(int x, int y)
Definition: nuklear.h:1183
struct nk_vec2 contextual_padding
Definition: nuklear.h:3644
Definition: nuklear.h:2041
nk_panel_flags
Definition: nuklear.h:1173
NK_API int nk_utf_decode(const char *, nk_rune *, int)
struct nk_style_button menu_button
Definition: nuklear.h:3659
Definition: nuklear.h:1895
NK_API struct nk_color nk_rgba_u32(nk_uint)
nk_size needed
Definition: nuklear.h:2575
NK_API int nk_filter_hex(const struct nk_text_edit *, nk_rune unicode)
NK_API int nk_menu_item_image_text(struct nk_context *, struct nk_image, const char *, int len, nk_flags alignment)
float bar_height
Definition: nuklear.h:3376
unsigned short w
Definition: nuklear.h:2885
NK_API void nk_buffer_init(struct nk_buffer *, const struct nk_allocator *, nk_size size)
NK_API int nk_button_color(struct nk_context *, struct nk_color)
unsigned short h
Definition: nuklear.h:2927
NK_API int nk_select_image_text(struct nk_context *, struct nk_image, const char *, int, nk_flags align, int value)
NK_API struct nk_window * nk_window_find(struct nk_context *ctx, const char *name)
NK_API void nk_str_remove_chars(struct nk_str *, int len)
NK_API int nk_widget_is_hovered(struct nk_context *)
#define NK_FLAGS_STACK_SIZE
Definition: nuklear.h:3917
NK_API void nk_layout_row_end(struct nk_context *)
Definition: nuklear.h:2819
Definition: nuklear.h:664
NK_API void nk_fill_circle(struct nk_command_buffer *, struct nk_rect, struct nk_color)
NK_API void nk_window_set_size(struct nk_context *, struct nk_vec2)
struct nk_vec2 padding
Definition: nuklear.h:3260
#define nk_zero_struct(s)
Definition: nuklear.h:4071
struct nk_image img
Definition: nuklear.h:462
Definition: nuklear.h:3799
Definition: deflate.c:117
Definition: nuklear.h:2552
nk_handle handle
Definition: nuklear.h:461
float border
Definition: nuklear.h:3504
Definition: nuklear.h:453
unsigned int seq
Definition: nuklear.h:3819
Definition: nuklear.h:3696
short x
Definition: nuklear.h:2851
enum nk_symbol_type sym_left
Definition: nuklear.h:3500
struct nk_config_stack_button_behavior button_behaviors
Definition: nuklear.h:3959
struct nk_rect clip
Definition: nuklear.h:3771
short y
Definition: nuklear.h:2891
Definition: nuklear.h:670
nk_modify
Definition: nuklear.h:467
Definition: nuklear.h:484
struct nk_color selected_text_hover
Definition: nuklear.h:3476
NK_API int nk_combo_callback(struct nk_context *, void(*item_getter)(void *, int, const char **), void *userdata, int selected, int count, int item_height, struct nk_vec2 size)
NK_API int nk_input_is_mouse_click_down_in_rect(const struct nk_input *i, enum nk_buttons id, struct nk_rect b, int down)
short h
Definition: nuklear.h:458
NK_API void nk_str_init_fixed(struct nk_str *, void *memory, nk_size size)
Definition: nuklear.h:3817
struct nk_color col
Definition: nuklear.h:2976
NK_API int nk_popup_begin(struct nk_context *, enum nk_popup_type, const char *, nk_flags, struct nk_rect bounds)
NK_API void nk_property_float(struct nk_context *, const char *name, float min, float *val, float max, float step, float inc_per_pixel)
NK_API void nk_layout_row_template_push_variable(struct nk_context *, float min_width)
nk_style_header_align
Definition: nuklear.h:3584
struct nk_vec2 touch_padding
Definition: nuklear.h:3310
Definition: nuklear.h:1887
NK_API int nk_button_text_styled(struct nk_context *, const struct nk_style_button *, const char *title, int len)
struct nk_row_layout row
Definition: nuklear.h:3773
unsigned short line_thickness
Definition: nuklear.h:2966
unsigned int seq
Definition: nuklear.h:3969
struct nk_style_button node_maximize_button
Definition: nuklear.h:3571
NK_API void nk_layout_space_push(struct nk_context *, struct nk_rect)
NK_API void nk_layout_row_template_push_static(struct nk_context *, float width)
int cursor
Definition: nuklear.h:3834
NK_API void nk_color_hsv_iv(int *hsv_out, struct nk_color)
struct nk_vec2 tooltip_padding
Definition: nuklear.h:3646
Definition: nuklear.h:465
NK_API void nk_combobox_callback(struct nk_context *, void(*item_getter)(void *, int, const char **), void *, int *selected, int count, int item_height, struct nk_vec2 size)
NK_API int nk_combo_item_text(struct nk_context *, const char *, int, nk_flags alignment)
Definition: nuklear.h:683
NK_API nk_flags nk_edit_string_zero_terminated(struct nk_context *, nk_flags, char *buffer, int max, nk_plugin_filter)
struct nk_window * current
Definition: nuklear.h:4039
NK_API void nk_text(struct nk_context *, const char *, int, nk_flags)
nk_flags flags
Definition: nuklear.h:3847
Definition: nuklear.h:2832
Definition: nuklear.h:3692
struct nk_color color
Definition: nuklear.h:2913
Definition: nuklear.h:3701
Definition: nuklear.h:3993
nk_uint values[NK_VALUE_PAGE_CAPACITY]
Definition: nuklear.h:3971
Definition: nuklear.h:1878
float border
Definition: nuklear.h:3526
NK_API int nk_select_label(struct nk_context *, const char *, nk_flags align, int value)
float h
Definition: nuklear.h:3716
NK_API int nk_menu_item_label(struct nk_context *, const char *, nk_flags alignment)
struct nk_color color
Definition: nuklear.h:2860
Definition: nuklear.h:3729
float cursor_size
Definition: nuklear.h:3481
struct nk_vec2i c
Definition: nuklear.h:2904
struct nk_color selected_text_normal
Definition: nuklear.h:3475
Definition: nuklear.h:3518
float w
Definition: nuklear.h:3716
Definition: nuklear.h:1750
NK_API int nk_button_symbol_styled(struct nk_context *, const struct nk_style_button *, enum nk_symbol_type)
float item_height
Definition: nuklear.h:3739
struct nk_color color
Definition: nuklear.h:2869
struct nk_chart_slot slots[NK_CHART_MAX_SLOT]
Definition: nuklear.h:3717
float border
Definition: nuklear.h:3312
struct nk_color text_normal_active
Definition: nuklear.h:3337
char nk_glyph[NK_UTF_SIZE]
Definition: nuklear.h:459
nk_plugin_free free
Definition: nuklear.h:487
NK_POINTER_TYPE nk_ptr
Definition: nuklear.h:402
NK_API struct nk_rect nk_layout_space_rect_to_local(struct nk_context *, struct nk_rect)
Definition: nuklear.h:492
nk_handle texture
Definition: nuklear.h:978
Definition: nuklear.h:1678
NK_API struct nk_color nk_hsv(int h, int s, int v)
struct nk_chart chart
Definition: nuklear.h:3774
struct nk_color tooltip_border_color
Definition: nuklear.h:3624
struct nk_vec2 image_padding
Definition: nuklear.h:3347
int where
Definition: nuklear.h:2698
nk_flags text_alignment
Definition: nuklear.h:3341
struct nk_vec2 cursor_size
Definition: nuklear.h:3379
struct nk_color group_border_color
Definition: nuklear.h:3623
struct nk_style_item scaler
Definition: nuklear.h:3625
Definition: nuklear.h:1174
#define NK_ABS(a)
Definition: nuklear.h:4055
nk_buttons
Definition: nuklear.h:695
NK_API void nk_edit_focus(struct nk_context *, nk_flags flags)
unsigned short point_count
Definition: nuklear.h:2952
Definition: nuklear.h:476
#define NK_MAX_FLOAT_PRECISION
Definition: nuklear.h:4050
#define NK_MAX_NUMBER_BUFFER
Definition: nuklear.h:260
unsigned char ungrab
Definition: nuklear.h:3056
short insert_length
Definition: nuklear.h:2699
short x
Definition: nuklear.h:2918
Definition: nuklear.h:3721
nk_edit_types
Definition: nuklear.h:1891
NK_API struct nk_color nk_hsv_fv(const float *hsv)
NK_API struct nk_style_item nk_style_item_image(struct nk_image img)
Definition: nuklear.h:1894
nk_anti_aliasing
Definition: nuklear.h:969
NK_API int nk_widget_is_mouse_clicked(struct nk_context *, enum nk_buttons)
struct nk_color bar_hover
Definition: nuklear.h:3364
struct nk_style_progress progress
Definition: nuklear.h:3664
NK_API void nk_window_collapse(struct nk_context *, const char *name, enum nk_collapse_states state)
Definition: nuklear.h:3690
short y
Definition: nuklear.h:458
Definition: nuklear.h:2054
NK_API void nk_button_set_behavior(struct nk_context *, enum nk_button_behavior)
nk_handle userdata
Definition: nuklear.h:2692
NK_API void nk_group_end(struct nk_context *)
NK_API int nk_input_is_key_pressed(const struct nk_input *, enum nk_keys)
unsigned short point_count
Definition: nuklear.h:2959
struct nk_style_item normal
Definition: nuklear.h:3322
#define NK_FLAG(x)
Definition: nuklear.h:290
unsigned short w
Definition: nuklear.h:2877
int32_t current
Definition: netobject.cpp:37
unsigned short line_thickness
Definition: nuklear.h:2857
#define NK_UTF_INVALID
Definition: nuklear.h:4049
unsigned short h
Definition: nuklear.h:2974
struct nk_color top
Definition: nuklear.h:2894
Definition: nuklear.h:3691
struct nk_property_state property
Definition: nuklear.h:3856
NK_API void nk_layout_space_end(struct nk_context *)
#define NK_GLOBAL
Definition: nuklear.h:288
struct nk_style_item active
Definition: nuklear.h:3457
struct nk_style_item cursor_hover
Definition: nuklear.h:3370
nk_flags flags
Definition: nuklear.h:3762
struct nk_color border_color
Definition: nuklear.h:3618
struct nk_color text_pressed
Definition: nuklear.h:3334
Definition: nuklear.h:1902
NK_API void nk_layout_row_template_push_dynamic(struct nk_context *)
short y
Definition: nuklear.h:2876
float min
Definition: nuklear.h:3708
unsigned short w
Definition: nuklear.h:2974
struct nk_page_element * freelist
Definition: nuklear.h:4040
Definition: nuklear.h:2724
Definition: nuklear.h:2889
NK_API int k_button_symbol_label_styled(struct nk_context *, const struct nk_style_button *, enum nk_symbol_type, const char *, nk_flags text_alignment)
struct nk_vec2i c
Definition: nuklear.h:2912
struct nk_style_selectable selectable
Definition: nuklear.h:3662
NK_API int nk_str_insert_str_runes(struct nk_str *, int pos, const nk_rune *)
void(* draw_begin)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:3514
enum nk_symbol_type sym_minimize
Definition: nuklear.h:3573
struct nk_style_button inc_button
Definition: nuklear.h:3383
nk_handle userdata
Definition: nuklear.h:3315
#define NK_ALIGNOF(t)
Definition: nuklear.h:4114
Definition: nuklear.h:969
struct nk_style_window window
Definition: nuklear.h:3672
float height
Definition: nuklear.h:3735
unsigned char grab
Definition: nuklear.h:3054
int select_start
Definition: nuklear.h:2731
struct nk_vec2i ctrl[2]
Definition: nuklear.h:2868
float group_border
Definition: nuklear.h:3631
NK_API void nk_stroke_triangle(struct nk_command_buffer *, float, float, float, float, float, float, float line_thichness, struct nk_color)
NK_SIZE_TYPE nk_size
Definition: nuklear.h:401
unsigned short w
Definition: nuklear.h:2852
Definition: nuklear.h:3788
unsigned short line_thickness
Definition: nuklear.h:2901
struct nk_color border_color
Definition: nuklear.h:3458
struct nk_color text_normal
Definition: nuklear.h:3332
nk_panel_row_layout_type
Definition: nuklear.h:3720
struct nk_style_button contextual_button
Definition: nuklear.h:3658
Definition: nuklear.h:3059
NK_API void nk_label_wrap(struct nk_context *, const char *)
NK_API struct nk_color nk_hsv_bv(const nk_byte *hsv)
Definition: nuklear.h:465
NK_API int nk_strmatch_fuzzy_text(const char *txt, int txt_len, const char *pattern, int *out_score)
NK_API void nk_window_set_focus(struct nk_context *, const char *name)
Definition: nuklear.h:1175
Definition: nuklear.h:2030
NK_API void nk_str_delete_runes(struct nk_str *, int pos, int len)
#define NK_POINTER_TYPE
Definition: nuklear.h:389
Definition: nuklear.h:663
::std::string string
Definition: gtest-port.h:872
unsigned int seq
Definition: nuklear.h:3838
NK_API struct nk_color nk_hsva_bv(const nk_byte *hsva)
#define SEEK_END
Definition: zconf.h:390
NK_API int nk_utf_encode(nk_rune, char *, int)
NK_API void nk_color_hsv_f(float *out_h, float *out_s, float *out_v, struct nk_color)
nk_byte r
Definition: nuklear.h:453
float a[2]
Definition: nuklear.h:2936
Definition: nuklear.h:2719
NK_API int nk_str_append_text_char(struct nk_str *, const char *, int)
struct nk_color border_color
Definition: nuklear.h:3536
NK_API void nk_fill_rect_multi_color(struct nk_command_buffer *, struct nk_rect, struct nk_color left, struct nk_color top, struct nk_color right, struct nk_color bottom)
struct nk_memory memory
Definition: nuklear.h:2569
NK_API void nk_list_view_end(struct nk_list_view *)
struct nk_color color
Definition: nuklear.h:2965
float header_height
Definition: nuklear.h:3768
void(* draw_end)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:3417
NK_API struct nk_vec2 nk_layout_space_to_local(struct nk_context *, struct nk_vec2)
struct nk_image img
Definition: nuklear.h:2975
NK_API char * nk_str_at_rune(struct nk_str *, int pos, nk_rune *unicode, int *len)
struct nk_mouse_button buttons[NK_BUTTON_MAX]
Definition: nuklear.h:3049
Definition: nuklear.h:1722
unsigned char has_preferred_x
Definition: nuklear.h:2736
NK_API struct nk_rect nk_layout_space_rect_to_screen(struct nk_context *, struct nk_rect)
struct nk_window * parent
Definition: nuklear.h:3868
int index
Definition: nuklear.h:3734
Definition: nuklear.h:458
union nk_style_item_data data
Definition: nuklear.h:3255
float border
Definition: nuklear.h:3374
Definition: nuklear.h:691
NK_API nk_uint nk_color_u32(struct nk_color)
NK_API struct nk_vec2 nk_widget_position(struct nk_context *)
struct nk_color background
Definition: nuklear.h:3616
NK_API int nk_button_symbol_text(struct nk_context *, enum nk_symbol_type, const char *, int, nk_flags alignment)
NK_API int nk_filter_ascii(const struct nk_text_edit *, nk_rune unicode)
Definition: nuklear.h:3694
struct nk_color bottom
Definition: nuklear.h:2895
nk_popup_type
Definition: nuklear.h:474
int prev
Definition: nuklear.h:3831
NK_API int nk_contextual_item_text(struct nk_context *, const char *, int, nk_flags align)
struct nk_page_element * next
Definition: nuklear.h:3983
nk_uint nk_flags
Definition: nuklear.h:405
float at_x
Definition: nuklear.h:3766
Definition: nuklear.h:3244
NK_API int nk_str_insert_text_char(struct nk_str *, int pos, const char *, int)
int count
Definition: nuklear.h:3709
struct nk_window * active
Definition: nuklear.h:4038
struct nk_color highlight
Definition: nuklear.h:3707
struct nk_color color
Definition: nuklear.h:3523
float rounding
Definition: nuklear.h:3578
float at_y
Definition: nuklear.h:3766
Definition: nuklear.h:2826
struct nk_style_text text
Definition: nuklear.h:3656
struct nk_vec2i b
Definition: nuklear.h:2911
nk_handle userdata
Definition: nuklear.h:3350
struct nk_color text_pressed_active
Definition: nuklear.h:3339
struct nk_color label_normal
Definition: nuklear.h:3539
struct nk_color combo_border_color
Definition: nuklear.h:3620
NK_API void nk_textedit_text(struct nk_text_edit *, const char *, int total_len)
NK_API void nk_str_delete_chars(struct nk_str *, int pos, int len)
Definition: nuklear.h:2835
struct nk_color color
Definition: nuklear.h:3250
struct nk_allocator alloc
Definition: nuklear.h:3994
NK_API int nk_str_append_text_runes(struct nk_str *, const nk_rune *, int)
#define NK_INT8
Definition: nuklear.h:337
nk_command_custom_callback callback
Definition: nuklear.h:2986
Definition: nuklear.h:668
std::mutex m
Definition: faio.cpp:21
NK_API void nk_color_f(float *r, float *g, float *b, float *a, struct nk_color)
Definition: nuklear.h:2546
NK_INT8 nk_char
Definition: nuklear.h:394
NK_API void nk_color_hsv_bv(nk_byte *hsv_out, struct nk_color)
Definition: nuklear.h:1881
struct nk_table * tables
Definition: nuklear.h:3861
struct nk_vec2 scrollbar_size
Definition: nuklear.h:3637
NK_API int nk_strtoi(const char *str, const char **endptr)
float max
Definition: nuklear.h:3708
struct nk_vec2 prev
Definition: nuklear.h:3051
enum nk_symbol_type sym_normal
Definition: nuklear.h:3550
Definition: nuklear.h:1880
Definition: nuklear.h:2721
struct nk_table * next
Definition: nuklear.h:3972
struct nk_style_item cursor_hover
Definition: nuklear.h:3403
struct nk_key keys[NK_KEY_MAX]
Definition: nuklear.h:3064
Definition: nuklear.h:3968
NK_API struct nk_style_item nk_style_item_hide(void)
NK_API int nk_combo_item_symbol_text(struct nk_context *, enum nk_symbol_type, const char *, int, nk_flags alignment)
unsigned short line_thickness
Definition: nuklear.h:2951
NK_API void nk_label(struct nk_context *, const char *, nk_flags align)
nk_byte g
Definition: nuklear.h:453
Definition: nuklear.h:1715
NK_API int nk_style_set_cursor(struct nk_context *, enum nk_style_cursor)
Definition: nuklear.h:3714
int count
Definition: nuklear.h:1680
NK_API const struct nk_command * nk__next(struct nk_context *, const struct nk_command *)
nk_tree_type
Definition: nuklear.h:476
NK_API int nk_stricmp(const char *s1, const char *s2)
Definition: nuklear.h:3487
NK_API int nk_str_insert_at_rune(struct nk_str *, int pos, const char *, int)
NK_API void nk_plot(struct nk_context *, enum nk_chart_type, const float *values, int count, int offset)
unsigned curve_segment_count
Definition: nuklear.h:987
nk_panel_type
Definition: nuklear.h:3689
short undo_point
Definition: nuklear.h:2707
int cursor
Definition: nuklear.h:2730
void(* draw_begin)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:3390
float delta_time_seconds
Definition: nuklear.h:4013
NK_API void nk_contextual_end(struct nk_context *)
NK_API int nk_combo_item_symbol_label(struct nk_context *, enum nk_symbol_type, const char *, nk_flags alignment)
struct nk_command_buffer overlay
Definition: nuklear.h:4030
struct nk_command header
Definition: nuklear.h:2873
NK_API int nk_progress(struct nk_context *, nk_size *cur, nk_size max, int modifyable)
float rounding
Definition: nuklear.h:3408
short y
Definition: nuklear.h:2973
nk_size needed
Definition: nuklear.h:2541
struct nk_style_item normal
Definition: nuklear.h:3533
struct nk_vec2i begin
Definition: nuklear.h:2858
Definition: nuklear.h:1743
void(* draw_begin)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:3351
struct nk_buffer buffer
Definition: nuklear.h:2609
struct nk_vec2i a
Definition: nuklear.h:2902
struct nk_style_item active
Definition: nuklear.h:3398
struct nk_style_edit edit
Definition: nuklear.h:3666
NK_API int nk_window_is_any_hovered(struct nk_context *)
Definition: nuklear.h:473
Definition: nuklear.h:3048
NK_API struct nk_vec2 nk_vec2iv(const int *xy)
unsigned short h
Definition: nuklear.h:2852
short cy
Definition: nuklear.h:2933
Definition: nuklear.h:969
unsigned char cursor_at_end_of_line
Definition: nuklear.h:2734
float border
Definition: nuklear.h:3627
NK_API int nk_combo_begin_text(struct nk_context *, const char *selected, int, struct nk_vec2 size)
#define NK_BUTTON_BEHAVIOR_STACK_SIZE
Definition: nuklear.h:3897
struct nk_style_button dec_button
Definition: nuklear.h:3384
NK_API void nk_input_glyph(struct nk_context *, const nk_glyph)
struct nk_style_item pressed_active
Definition: nuklear.h:3329
Definition: nuklear.h:475
nk_button_behavior
Definition: nuklear.h:466
NK_API struct nk_vec2 nk_layout_space_to_screen(struct nk_context *, struct nk_vec2)
NK_API int nk_style_pop_float(struct nk_context *)
short y
Definition: nuklear.h:2983
float rounding
Definition: nuklear.h:3505
NK_API struct nk_rect nk_layout_space_bounds(struct nk_context *)
struct nk_table * prev
Definition: nuklear.h:3972
NK_API int nk_button_image_text_styled(struct nk_context *, const struct nk_style_button *, struct nk_image img, const char *, int, nk_flags alignment)
NK_API int nk_init_custom(struct nk_context *, struct nk_buffer *cmds, struct nk_buffer *pool, const struct nk_user_font *)
struct nk_vec2i points[1]
Definition: nuklear.h:2953
Definition: nuklear.h:661
struct nk_style_tab tab
Definition: nuklear.h:3670
struct nk_color border_color
Definition: nuklear.h:3295
NK_API enum nk_widget_layout_states nk_widget_fitting(struct nk_rect *, struct nk_context *, struct nk_vec2)
NK_API double nk_strtod(const char *str, const char **endptr)
struct nk_window win
Definition: nuklear.h:3978
NK_API void nk_window_close(struct nk_context *ctx, const char *name)
struct nk_clipboard clip
Definition: nuklear.h:2725
nk_style_cursor
Definition: nuklear.h:2047
struct nk_window * begin
Definition: nuklear.h:4036
NK_API void nk_style_default(struct nk_context *)
NK_API void nk_input_scroll(struct nk_context *, struct nk_vec2 val)
NK_API int nk_input_has_mouse_click_down_in_rect(const struct nk_input *, enum nk_buttons, struct nk_rect, int down)
#define NK_FLOAT_STACK_SIZE
Definition: nuklear.h:3909
Definition: nuklear.h:1719
Definition: nuklear.h:3394
Definition: nuklear.h:2837
Definition: nuklear.h:3699
float y
Definition: nuklear.h:3716
Definition: nuklear.h:3700
int active
Definition: nuklear.h:3831
Definition: nuklear.h:665
NK_API void nk_free(struct nk_context *)
struct nk_color text_normal
Definition: nuklear.h:3468
unsigned short point_count
Definition: nuklear.h:2967
Definition: nuklear.h:496
int buffer_size
Definition: versiongenerate.py:65
Definition: nuklear.h:971
NK_API char * nk_str_at_char(struct nk_str *, int pos)
Definition: nuklear.h:699
Definition: nuklear.h:697
NK_API int nk_button_label_styled(struct nk_context *, const struct nk_style_button *, const char *title)
NK_API struct nk_color nk_rgb(int r, int g, int b)
NK_API int nk_tree_push_hashed(struct nk_context *, enum nk_tree_type, const char *title, enum nk_collapse_states initial_state, const char *hash, int len, int seed)
Definition: nuklear.h:474
enum nk_symbol_type sym_active
Definition: nuklear.h:3552
Definition: nuklear.h:500
NK_API void nk_combobox_separator(struct nk_context *, const char *items_separated_by_separator, int separator, int *selected, int count, int item_height, struct nk_vec2 size)
unsigned int has_scrolling
Definition: nuklear.h:3770
int len
Definition: nuklear.h:2610
unsigned int type
Definition: nuklear.h:2538
NK_API void nk_tree_state_pop(struct nk_context *)
NK_API int nk_combo_begin_label(struct nk_context *, const char *selected, struct nk_vec2 size)
NK_API int nk_stricmpn(const char *s1, const char *s2, int n)
Definition: nuklear.h:672
#define NK_UINT32
Definition: nuklear.h:359
NK_API int nk_style_push_flags(struct nk_context *, nk_flags *, nk_flags)
int select_start
Definition: nuklear.h:3835
int index
Definition: nuklear.h:3711
struct nk_style_item active
Definition: nuklear.h:3535
NK_API void nk_window_collapse_if(struct nk_context *, const char *name, enum nk_collapse_states, int cond)
Definition: nuklear.h:1888
struct nk_vec2 button_padding
Definition: nuklear.h:3558
Definition: nuklear.h:1741
float contextual_border
Definition: nuklear.h:3629
Definition: nuklear.h:2039
Definition: nuklear.h:1181
char text[NK_INPUT_MAX]
Definition: nuklear.h:3065
void(* nk_plugin_copy)(nk_handle, const char *, int len)
Definition: nuklear.h:482
unsigned char active
Definition: nuklear.h:2738
float templates[NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS]
Definition: nuklear.h:3744
NK_API void nk_buffer_push(struct nk_buffer *, enum nk_buffer_allocation_type type, const void *memory, nk_size size, nk_size align)
NK_API struct nk_vec2 nk_window_get_position(const struct nk_context *ctx)
NK_API void nk_color_fv(float *rgba_out, struct nk_color)
int state
Definition: nuklear.h:3840
NK_API int nk_input_is_mouse_prev_hovering_rect(const struct nk_input *, struct nk_rect)
Definition: nuklear.h:2715
Definition: nuklear.h:3453
nk_keys
Definition: nuklear.h:660
unsigned arc_segment_count
Definition: nuklear.h:986
#define NK_INT16
Definition: nuklear.h:343
struct nk_command header
Definition: nuklear.h:2972
Definition: nuklear.h:2829
Definition: nuklear.h:3585
NK_API void nk_layout_row_static(struct nk_context *ctx, float height, int item_width, int cols)
nk_size end
Definition: nuklear.h:3011
nk_style_item_type
Definition: nuklear.h:3243
const struct nk_cursor * cursor_active
Definition: nuklear.h:3652
Definition: nuklear.h:2556
unsigned circle_segment_count
Definition: nuklear.h:985
enum nk_symbol_type dec_symbol
Definition: nuklear.h:3386
int prev
Definition: nuklear.h:3821
struct nk_command header
Definition: nuklear.h:2900
Definition: nuklear.h:2608
struct nk_command header
Definition: nuklear.h:2850
Definition: nuklear.h:2033
Definition: nuklear.h:1882
Definition: nuklear.h:467
Definition: nuklear.h:3793
struct nk_vec2i b
Definition: nuklear.h:2903
struct nk_style_button button
Definition: nuklear.h:3657
Definition: nuklear.h:1177
struct nk_style_scrollbar scrollh
Definition: nuklear.h:3668
Definition: nuklear.h:1718
NK_API int nk_input_is_mouse_click_in_rect(const struct nk_input *, enum nk_buttons, struct nk_rect)
NK_API void nk_group_scrolled_end(struct nk_context *)
const float * ratio
Definition: nuklear.h:3737
NK_API int nk_contextual_item_symbol_label(struct nk_context *, enum nk_symbol_type, const char *, nk_flags alignment)
unsigned char single_line
Definition: nuklear.h:2737
Definition: nuklear.h:1892
Definition: nuklear.h:1178
struct nk_color foreground
Definition: nuklear.h:2993
struct nk_vec2 padding
Definition: nuklear.h:3640
Definition: nuklear.h:2025
struct nk_table tbl
Definition: nuklear.h:3976
struct nk_panel * parent
Definition: nuklear.h:3776
struct nk_style_item normal
Definition: nuklear.h:3489
struct nk_vec2 scrollbar
Definition: nuklear.h:2728
NK_API struct nk_vec2 nk_vec2(float x, float y)
unsigned char padding1
Definition: nuklear.h:2739
NK_API void nk_menubar_end(struct nk_context *)
struct nk_vec2 scrollbar_size
Definition: nuklear.h:3482
NK_API void nk_buffer_mark(struct nk_buffer *, enum nk_buffer_allocation_type type)
#define NK_WINDOW_MAX_NAME
Definition: nuklear.h:3783
Definition: nuklear.h:676
nk_uint * offset_x
Definition: nuklear.h:3764
int begin
Definition: nuklear.h:1680
typedef void(ENET_CALLBACK *ENetPacketFreeCallback)(struct _ENetPacket *)
struct nk_config_stack_user_font fonts
Definition: nuklear.h:3958
union nk_page_data data
Definition: nuklear.h:3982
Definition: nuklear.h:1885
NK_API int nk_combo_begin_symbol(struct nk_context *, enum nk_symbol_type, struct nk_vec2 size)
NK_API void nk_image(struct nk_context *, struct nk_image)
float footer_height
Definition: nuklear.h:3767
Definition: nuklear.h:2036
#define NK_VECTOR_STACK_SIZE
Definition: nuklear.h:3913
Definition: nuklear.h:2841
Definition: nuklear.h:3003
struct nk_draw_null_texture null
Definition: nuklear.h:988
NK_API void nk_layout_row_dynamic(struct nk_context *ctx, float height, int cols)
Definition: nuklear.h:3248
NK_API int nk_strlen(const char *str)
struct nk_style_item normal
Definition: nuklear.h:3455
float height
Definition: nuklear.h:2364
unsigned short rounding
Definition: nuklear.h:2883
Definition: nuklear.h:692
struct nk_page * next
Definition: nuklear.h:3989
NK_API float nk_strtof(const char *str, const char **endptr)
NK_UINT32 nk_uint
Definition: nuklear.h:400
struct nk_vec2 spacing
Definition: nuklear.h:3559
#define NK_SIZE_TYPE
Definition: nuklear.h:374
struct nk_color bar_active
Definition: nuklear.h:3365
Definition: nuklear.h:2822
Definition: nuklear.h:3613
struct nk_color cursor_text_normal
Definition: nuklear.h:3464
NK_API struct nk_color nk_rgb_fv(const float *rgb)
NK_API int nk_window_is_collapsed(struct nk_context *ctx, const char *name)
int tree_depth
Definition: nuklear.h:3743
NK_API void nk_layout_row_template_begin(struct nk_context *, float height)
NK_API void nk_draw_text(struct nk_command_buffer *, struct nk_rect, const char *text, int len, const struct nk_user_font *, struct nk_color, struct nk_color)
float b
Definition: nuklear.h:454
enum nk_allocation_type type
Definition: nuklear.h:3995
struct nk_command header
Definition: nuklear.h:2964
unsigned int seq
Definition: nuklear.h:3844
struct nk_buffer memory
Definition: nuklear.h:4008
nk_text_align
Definition: nuklear.h:1740
NK_API struct nk_color nk_hsva_iv(const int *hsva)
NK_API void nk_combobox(struct nk_context *, const char **items, int count, int *selected, int item_height, struct nk_vec2 size)
struct nk_scroll scrollbar
Definition: nuklear.h:3825
NK_API void nk_buffer_reset(struct nk_buffer *, enum nk_buffer_allocation_type type)
NK_API int nk_str_insert_text_runes(struct nk_str *, int pos, const nk_rune *, int)
enum nk_symbol_type sym_maximize
Definition: nuklear.h:3574
NK_API void nk_textedit_delete_selection(struct nk_text_edit *)
struct nk_window * end
Definition: nuklear.h:4037
Definition: nuklear.h:680
Definition: nuklear.h:2031
struct nk_rect item
Definition: nuklear.h:3742
NK_API void nk_color_hsva_bv(nk_byte *hsva_out, struct nk_color)
NK_API int nk_group_scrolled_offset_begin(struct nk_context *, nk_uint *x_offset, nk_uint *y_offset, const char *, nk_flags)
float item_offset
Definition: nuklear.h:3740
Definition: nuklear.h:461
struct nk_color text
Definition: nuklear.h:3566
NK_API struct nk_color nk_rgba(int r, int g, int b, int a)
Definition: nuklear.h:2553
NK_API void * nk_buffer_memory(struct nk_buffer *)
nk_text_edit_type
Definition: nuklear.h:2713
NK_API void nk_textedit_init_fixed(struct nk_text_edit *, void *memory, nk_size size)
NK_API int nk_init_fixed(struct nk_context *, void *memory, nk_size size, const struct nk_user_font *)
unsigned short h
Definition: nuklear.h:2885
#define NK_SATURATE(x)
Definition: nuklear.h:4053
struct nk_style_slider slider
Definition: nuklear.h:3663
struct nk_color label_active
Definition: nuklear.h:3497
Definition: nuklear.h:2022
Definition: nuklear.h:3728
NK_API void nk_stroke_curve(struct nk_command_buffer *, float, float, float, float, float, float, float, float, float line_thickness, struct nk_color)
float popup_border
Definition: nuklear.h:3633
NK_API int nk_button_image(struct nk_context *, struct nk_image img)
NK_API struct nk_image nk_subimage_handle(nk_handle, unsigned short w, unsigned short h, struct nk_rect sub_region)
nk_hash name
Definition: nuklear.h:3818
float border
Definition: nuklear.h:3555
NK_API int nk_combo(struct nk_context *, const char **items, int count, int selected, int item_height, struct nk_vec2 size)
Definition: nuklear.h:3843
Definition: nuklear.h:2043
Definition: nuklear.h:1182
nk_byte a
Definition: nuklear.h:453
NK_API struct nk_color nk_rgba_f(float r, float g, float b, float a)
NK_API void nk_str_clear(struct nk_str *)
float rounding
Definition: nuklear.h:3527
float a[2]
Definition: nuklear.h:2944
#define NK_TEXTEDIT_UNDOCHARCOUNT
Definition: nuklear.h:2687
NK_API const void * nk_buffer_memory_const(const struct nk_buffer *)
#define nk_ptr_add_const(t, p, i)
Definition: nuklear.h:4070
Definition: nuklear.h:2836
NK_API void nk_buffer_init_fixed(struct nk_buffer *, void *memory, nk_size size)
float x
Definition: nuklear.h:457
Definition: nuklear.h:977
Definition: nuklear.h:2020
NK_API void nk_popup_close(struct nk_context *)
NK_API void nk_stroke_line(struct nk_command_buffer *b, float x0, float y0, float x1, float y1, float line_thickness, struct nk_color)
Definition: nuklear.h:2032
short x
Definition: nuklear.h:2994
nk_uint nk_rune
Definition: nuklear.h:406
struct nk_page_element * freelist
Definition: nuklear.h:3998
struct nk_window * next
Definition: nuklear.h:3866
NK_API struct nk_color nk_color_picker(struct nk_context *, struct nk_color, enum nk_color_format)
struct nk_vec2 combo_padding
Definition: nuklear.h:3643
NK_API int nk_str_append_text_utf8(struct nk_str *, const char *, int)
struct nk_color text_hover
Definition: nuklear.h:3303
NK_API void nk_text_colored(struct nk_context *, const char *, int, nk_flags, struct nk_color)
int end
Definition: nuklear.h:1680
struct nk_config_stack_flags flags
Definition: nuklear.h:3956
nk_panel_set
Definition: nuklear.h:3698
unsigned short w
Definition: nuklear.h:2995
float x
Definition: nuklear.h:3716
struct nk_image image
Definition: nuklear.h:3249
float cursor_rounding
Definition: nuklear.h:3411
NK_API int nk_checkbox_flags_text(struct nk_context *, const char *, int, unsigned int *flags, unsigned int value)
Definition: nuklear.h:3975
NK_API int nk_button_image_styled(struct nk_context *, const struct nk_style_button *, struct nk_image img)
unsigned short line_thickness
Definition: nuklear.h:2865
int total_height
Definition: nuklear.h:1682
NK_API struct nk_rect nk_rect(float x, float y, float w, float h)
Definition: nuklear.h:3797
nk_orientation
Definition: nuklear.h:468
NK_API void nk_style_show_cursor(struct nk_context *)
struct nk_color text_background
Definition: nuklear.h:3340
struct nk_window * prev
Definition: nuklear.h:3867
int cursor
Definition: nuklear.h:3822
struct nk_vec2 min_size
Definition: nuklear.h:3638
struct nk_command header
Definition: nuklear.h:2932
struct nk_color color
Definition: nuklear.h:2928
float spacing
Definition: nuklear.h:3311
Definition: nuklear.h:2823
nk_widget_layout_states
Definition: nuklear.h:1709
Definition: nuklear.h:2830
struct nk_style_scrollbar scrollv
Definition: nuklear.h:3669
NK_API void nk_chart_add_slot_colored(struct nk_context *ctx, const enum nk_chart_type, struct nk_color, struct nk_color active, int count, float min_value, float max_value)
enum nk_anti_aliasing line_AA
Definition: nuklear.h:983
nk_collapse_states
Definition: nuklear.h:469
short redo_point
Definition: nuklear.h:2708
NK_API const char * nk_utf_at(const char *buffer, int length, int index, nk_rune *unicode, int *len)
Definition: nuklear.h:499
Definition: nuklear.h:456
NK_API int nk_chart_begin_colored(struct nk_context *, enum nk_chart_type, struct nk_color, struct nk_color active, int num, float min, float max)
NK_API void nk_style_hide_cursor(struct nk_context *)
NK_API int nk_menu_begin_image_text(struct nk_context *, const char *, int, nk_flags align, struct nk_image, struct nk_vec2 size)
Definition: nuklear.h:3724
struct nk_color border_color
Definition: nuklear.h:3360
Definition: nuklear.h:1712
Definition: nuklear.h:2024
NK_API int nk_group_scrolled_begin(struct nk_context *, struct nk_scroll *, const char *title, nk_flags)
struct nk_color color
Definition: nuklear.h:2886
NK_API void nk_str_remove_runes(struct nk_str *str, int len)
struct nk_vec2 spacing
Definition: nuklear.h:3636
float item_width
Definition: nuklear.h:3738
Definition: nuklear.h:2825
Definition: nuklear.h:2049
Definition: nuklear.h:3355
#define NK_ALIGN_PTR(x, mask)
Definition: nuklear.h:4091
struct nk_color color
Definition: nuklear.h:2905
int cursor_visible
Definition: nuklear.h:3654
NK_API int nk_widget_has_mouse_click_down(struct nk_context *, enum nk_buttons, int down)
#define NK_CLAMP(i, v, x)
Definition: nuklear.h:317
struct nk_style_combo combo
Definition: nuklear.h:3671
struct nk_style_property property
Definition: nuklear.h:3665
unsigned short region[4]
Definition: nuklear.h:461
NK_API void nk_input_begin(struct nk_context *)
int length
Definition: nuklear.h:3833
struct nk_color contextual_border_color
Definition: nuklear.h:3621
Definition: nuklear.h:2908
NK_API int nk_option_text(struct nk_context *, const char *, int, int active)
void * ptr
Definition: nuklear.h:460
struct nk_menu_state menu
Definition: nuklear.h:3772
NK_API void nk_stroke_rect(struct nk_command_buffer *, struct nk_rect, float rounding, float line_thickness, struct nk_color)
NK_API int nk_menu_begin_symbol_text(struct nk_context *, const char *, int, nk_flags align, enum nk_symbol_type, struct nk_vec2 size)
NK_API void nk_push_scissor(struct nk_command_buffer *, struct nk_rect)
NK_API const struct nk_command * nk__begin(struct nk_context *)
NK_API nk_flags nk_chart_push_slot(struct nk_context *, float, int)
Definition: nuklear.h:2027
nk_edit_flags
Definition: nuklear.h:1876
#define NK_INBOX(px, py, x, y, w, h)
Definition: nuklear.h:4057
int value
Definition: der_length_ia5_string.c:21
#define nk_vec2_sub(a, b)
Definition: nuklear.h:4064
Definition: nuklear.h:470
NK_API int nk_str_append_str_char(struct nk_str *, const char *)
float indent
Definition: nuklear.h:3579
Definition: nuklear.h:700
struct nk_color selected_color
Definition: nuklear.h:3522
unsigned char initialized
Definition: nuklear.h:2735
Definition: nuklear.h:2028
Definition: nuklear.h:1180
NK_API int nk_input_is_key_down(const struct nk_input *, enum nk_keys)
Definition: nuklear.h:501
NK_API int nk_window_is_hovered(struct nk_context *)
short x
Definition: nuklear.h:2973
NK_API double nk_propertyd(struct nk_context *, const char *name, double min, double val, double max, double step, float inc_per_pixel)
#define NK_PI
Definition: nuklear.h:4048
struct nk_cursor * cursor_last
Definition: nuklear.h:3653
nk_size last
Definition: nuklear.h:3011
NK_API int nk_filter_decimal(const struct nk_text_edit *, nk_rune unicode)
Definition: nuklear.h:1898
Definition: nuklear.h:469
float height
Definition: nuklear.h:2996
NK_API int nk_filter_binary(const struct nk_text_edit *, nk_rune unicode)
NK_API int nk_init(struct nk_context *, struct nk_allocator *, const struct nk_user_font *)
Definition: nuklear.h:2029
NK_API int nk_radio_label(struct nk_context *, const char *, int *active)
NK_API void nk_contextual_close(struct nk_context *)
short y
Definition: nuklear.h:2918
NK_API int nk_input_has_mouse_click_in_rect(const struct nk_input *, enum nk_buttons, struct nk_rect)
void(* nk_command_custom_callback)(void *canvas, short x, short y, unsigned short w, unsigned short h, nk_handle callback_data)
Definition: nuklear.h:2979
NK_API void nk_textedit_init(struct nk_text_edit *, struct nk_allocator *, nk_size size)
const struct nk_cursor * cursors[NK_CURSOR_COUNT]
Definition: nuklear.h:3651
struct nk_vec2 spacing
Definition: nuklear.h:3378
const struct nk_draw_vertex_layout_element * vertex_layout
Definition: nuklear.h:989
struct nk_style_chart chart
Definition: nuklear.h:3667
#define NK_UTF_SIZE
Definition: nuklear.h:255
struct nk_vec2 popup_padding
Definition: nuklear.h:3642
NK_API void nk_layout_row_begin(struct nk_context *ctx, enum nk_layout_format fmt, float row_height, int cols)
short delete_length
Definition: nuklear.h:2700
NK_API void nk_fill_arc(struct nk_command_buffer *, float cx, float cy, float radius, float a_min, float a_max, struct nk_color)
NK_API const char * nk_str_get_const(const struct nk_str *)
NK_API int nk_textedit_cut(struct nk_text_edit *)
Definition: nuklear.h:972
NK_API void nk_property_double(struct nk_context *, const char *name, double min, double *val, double max, double step, float inc_per_pixel)
Definition: nuklear.h:3562
struct nk_color cursor_text_hover
Definition: nuklear.h:3465
NK_API int nk_button_image_label_styled(struct nk_context *, const struct nk_style_button *, struct nk_image img, const char *, nk_flags text_alignment)
NK_API int nk_combo_separator(struct nk_context *, const char *items_separated_by_separator, int separator, int selected, int count, int item_height, struct nk_vec2 size)
NK_API void nk_color_hsva_i(int *h, int *s, int *v, int *a, struct nk_color)
float rounding
Definition: nuklear.h:3375
NK_API void nk_stroke_polyline(struct nk_command_buffer *, float *points, int point_count, float line_thickness, struct nk_color col)
NK_API void nk_text_wrap_colored(struct nk_context *, const char *, int, struct nk_color)
NK_API enum nk_widget_layout_states nk_widget(struct nk_rect *, const struct nk_context *)
nk_edit_events
Definition: nuklear.h:1897
NK_API struct nk_vec2 nk_rect_pos(struct nk_rect)
Definition: nuklear.h:3723
struct nk_text_undo_state undo
Definition: nuklear.h:2741
NK_API int nk_input_is_mouse_released(const struct nk_input *, enum nk_buttons)
Definition: nuklear.h:2037
NK_API void nk_property_int(struct nk_context *, const char *name, int min, int *val, int max, int step, float inc_per_pixel)
struct nk_style_button button
Definition: nuklear.h:3549
#define NK_SCROLLBAR_HIDING_TIMEOUT
Definition: nuklear.h:263
enum nk_symbol_type sym_right
Definition: nuklear.h:3501
Definition: nuklear.h:3649
NK_API void nk_color_hex_rgba(char *output, struct nk_color)
#define NK_MIN(a, b)
Definition: nuklear.h:315
Definition: nuklear.h:3791
struct nk_vec2 group_padding
Definition: nuklear.h:3641
Definition: nuklear.h:468
nk_handle userdata
Definition: nuklear.h:485
NK_API void nk_style_load_cursor(struct nk_context *, enum nk_style_cursor, const struct nk_cursor *)
unsigned int size
Definition: nuklear.h:3988
Definition: nuklear.h:455
Definition: nuklear.h:457
NK_API int nk_input_is_mouse_pressed(const struct nk_input *, enum nk_buttons)
Definition: nuklear.h:2038
struct nk_style_item cursor_normal
Definition: nuklear.h:3369
#define NK_VALUE_PAGE_CAPACITY
Definition: nuklear.h:3965
Definition: nuklear.h:474
NK_API void nk_push_custom(struct nk_command_buffer *, struct nk_rect, nk_command_custom_callback, nk_handle usr)
Definition: nuklear.h:2956
Definition: nuklear.h:490
NK_API int nk_str_len_char(struct nk_str *)
int active
Definition: nuklear.h:2557
Definition: nuklear.h:2052
unsigned int clicked
Definition: nuklear.h:3061
NK_API int nk_input_any_mouse_click_in_rect(const struct nk_input *, struct nk_rect)
void * ptr
Definition: nuklear.h:2561
Definition: nuklear.h:2023
NK_API const char * nk_style_get_color_by_name(enum nk_style_colors)
void(* nk_query_font_glyph_f)(nk_handle handle, float font_height, struct nk_user_font_glyph *glyph, nk_rune codepoint, nk_rune next_codepoint)
Definition: nuklear.h:2344
Definition: nuklear.h:3727
NK_API void nk_stroke_arc(struct nk_command_buffer *, float cx, float cy, float radius, float a_min, float a_max, float line_thickness, struct nk_color)
Definition: nuklear.h:975
Definition: nuklear.h:2704
Definition: nuklear.h:662
nk_size vertex_alignment
Definition: nuklear.h:991
NK_API void nk_tooltip_end(struct nk_context *)
Definition: nuklear.h:679
Definition: nuklear.h:502
struct nk_color border_color
Definition: nuklear.h:3521
struct nk_style_item cursor_normal
Definition: nuklear.h:3402
unsigned short h
Definition: nuklear.h:2920
Definition: nuklear.h:1900
Definition: nuklear.h:503
short w
Definition: nuklear.h:458
NK_API void nk_spacing(struct nk_context *, int cols)
Definition: nuklear.h:467
Definition: nuklear.h:2536
Definition: nuklear.h:682
float y
Definition: nuklear.h:455
NK_API struct nk_color nk_rgba_hex(const char *rgb)
struct nk_vec2i points[1]
Definition: nuklear.h:2960
struct nk_vec2 padding
Definition: nuklear.h:3580
struct nk_command header
Definition: nuklear.h:2957
struct nk_style_item active
Definition: nuklear.h:3491
GLuint texture
Definition: sdl2backend.cpp:515
NK_API int nk_button_symbol_label(struct nk_context *, enum nk_symbol_type, const char *, nk_flags text_alignment)
#define NK_STATIC_ASSERT(exp)
Definition: nuklear.h:304
NK_API struct nk_image nk_subimage_ptr(void *, unsigned short w, unsigned short h, struct nk_rect sub_region)
NK_API void nk_text_wrap(struct nk_context *, const char *, int)
NK_API struct nk_image nk_image_handle(nk_handle)
NK_API struct nk_image nk_image_ptr(void *)
short y
Definition: nuklear.h:2926
NK_API float nk_window_get_width(const struct nk_context *)
NK_API int nk_image_is_subimage(const struct nk_image *img)
nk_size begin
Definition: nuklear.h:3011
struct nk_command header
Definition: nuklear.h:2882
Definition: nuklear.h:973
Definition: nuklear.h:1179
NK_API int nk_style_push_font(struct nk_context *, struct nk_user_font *)
struct nk_context * ctx
Definition: nuklear.h:1683
unsigned char mode
Definition: nuklear.h:2733
struct nk_style_item hover
Definition: nuklear.h:3358
unsigned short h
Definition: nuklear.h:2995
NK_API void nk_draw_image(struct nk_command_buffer *, struct nk_rect, const struct nk_image *, struct nk_color)
struct nk_color text_hover_active
Definition: nuklear.h:3338
NK_API int nk_selectable_label(struct nk_context *, const char *, nk_flags align, int *value)
struct nk_style_button tab_minimize_button
Definition: nuklear.h:3570
struct nk_vec2 padding
Definition: nuklear.h:3483
NK_API struct nk_color nk_hsva(int h, int s, int v, int a)
struct nk_vec2 spacing
Definition: nuklear.h:3581
#define NK_STYLE_ITEM_STACK_SIZE
Definition: nuklear.h:3905
Definition: nuklear.h:669
NK_API int nk_str_insert_text_utf8(struct nk_str *, int pos, const char *, int)
NK_API void nk_tooltip(struct nk_context *, const char *)
Definition: nuklear.h:2562
struct nk_color text_active
Definition: nuklear.h:3304
#define NK_MAX_LAYOUT_ROW_TEMPLATE_COLUMNS
Definition: nuklear.h:3683
nk_plugin_alloc alloc
Definition: nuklear.h:486
NK_API void nk_combo_close(struct nk_context *)
struct nk_color text_hover
Definition: nuklear.h:3469
NK_API int nk_radio_text(struct nk_context *, const char *, int, int *active)
NK_API void nk_buffer_clear(struct nk_buffer *)
Definition: nuklear.h:3760
nk_uint scroll_value
Definition: nuklear.h:1685
short undo_char_point
Definition: nuklear.h:2709
enum nk_symbol_type sym_hover
Definition: nuklear.h:3551
int id
Definition: nuklear.h:460
Definition: nuklear.h:2361
NK_API struct nk_vec2 nk_window_get_size(const struct nk_context *)
Definition: nuklear.h:465
nk_uint * offset_y
Definition: nuklear.h:3765
struct nk_command header
Definition: nuklear.h:2949
struct nk_color label_hover
Definition: nuklear.h:3496
Definition: nuklear.h:1717
int select_end
Definition: nuklear.h:2732
NK_API const char * nk_str_at_char_const(const struct nk_str *, int pos)
struct nk_configuration_stacks stacks
Definition: nuklear.h:4012
Definition: nuklear.h:1899
Definition: nuklear.h:2899
NK_API nk_handle nk_handle_id(int)
NK_API int nk_combo_item_image_label(struct nk_context *, struct nk_image, const char *, nk_flags alignment)
unsigned short h
Definition: nuklear.h:2892
NK_UINT8 nk_uchar
Definition: nuklear.h:395
int active
Definition: nuklear.h:3821
NK_API struct nk_color nk_rgb_f(float r, float g, float b)
Definition: nuklear.h:2720
enum nk_allocation_type type
Definition: nuklear.h:2567
float r
Definition: nuklear.h:454
nk_window_flags
Definition: nuklear.h:3787
short x
Definition: nuklear.h:2891
nk_chart_type
Definition: nuklear.h:471
float x
Definition: nuklear.h:455
struct nk_color symbol_hover
Definition: nuklear.h:3545
enum nk_chart_type type
Definition: nuklear.h:3705
Definition: nuklear.h:498
struct nk_rect bounds
Definition: nuklear.h:3763
Definition: nuklear.h:2017
Definition: nuklear.h:2547
NK_API int nk_contextual_item_label(struct nk_context *, const char *, nk_flags align)
#define NK_CONFIGURATION_STACK_TYPE(prefix, name, type)
Definition: nuklear.h:3924
NK_API int nk_list_view_begin(struct nk_context *, struct nk_list_view *out, const char *id, nk_flags, int row_height, int row_count)
float rounding
Definition: nuklear.h:3480
nk_size size
Definition: nuklear.h:4000
struct nk_vec2 padding
Definition: nuklear.h:3345
NK_API void nk_stroke_polygon(struct nk_command_buffer *, float *, int point_count, float line_thickness, struct nk_color)
NK_API void nk_popup_end(struct nk_context *)
int build
Definition: nuklear.h:4033
struct nk_page * pages
Definition: nuklear.h:3997
NK_API void nk_input_motion(struct nk_context *, int x, int y)
NK_API int nk_textedit_paste(struct nk_text_edit *, char const *, int len)
Definition: nuklear.h:3320
NK_API int nk_color_pick(struct nk_context *, struct nk_color *, enum nk_color_format)
Definition: nuklear.h:2828
NK_API int nk_utf_len(const char *, int byte_len)
float g
Definition: nuklear.h:454
Definition: nuklear.h:974
NK_API void nk_triangle_from_direction(struct nk_vec2 *result, struct nk_rect r, float pad_x, float pad_y, enum nk_heading)
Definition: nuklear.h:1716
nk_size vertex_size
Definition: nuklear.h:990
unsigned short w
Definition: nuklear.h:2920
Definition: nuklear.h:1720
NK_API struct nk_color nk_hsva_fv(const float *hsva)
Definition: nuklear.h:462
Definition: nuklear.h:696
nk_size cap
Definition: nuklear.h:4001
Definition: nuklear.h:1883
Definition: nuklear.h:1176
enum nk_symbol_type inc_symbol
Definition: nuklear.h:3385
NK_API void nk_color_hsva_b(nk_byte *h, nk_byte *s, nk_byte *v, nk_byte *a, struct nk_color)
Definition: nuklear.h:3987
unsigned short rounding
Definition: nuklear.h:2874
void(* draw_end)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:3352
#define NK_UINT16
Definition: nuklear.h:346
Definition: nuklear.h:475
unsigned short w
Definition: nuklear.h:461
Definition: nuklear.h:2924
unsigned short w
Definition: nuklear.h:2927
#define NK_TEXTEDIT_UNDOSTATECOUNT
Definition: nuklear.h:2683
void(* draw_end)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:3515
NK_API void nk_chart_add_slot(struct nk_context *ctx, const enum nk_chart_type, int count, float min_value, float max_value)
struct nk_style_scrollbar scrollbar
Definition: nuklear.h:3459
struct nk_color bar_normal
Definition: nuklear.h:3363
nk_flags last_widget_state
Definition: nuklear.h:4010
Definition: nuklear.h:3801
#define nk_foreach(c, ctx)
Definition: nuklear.h:1011
struct nk_color color
Definition: nuklear.h:3706
struct nk_command header
Definition: nuklear.h:2925
int(* nk_plugin_filter)(const struct nk_text_edit *, nk_rune unicode)
Definition: nuklear.h:480
struct nk_style_item normal_active
Definition: nuklear.h:3327
Definition: nuklear.h:476
NK_API float nk_window_get_height(const struct nk_context *)
NK_API float nk_widget_height(struct nk_context *)
NK_API int nk_menu_item_image_label(struct nk_context *, struct nk_image, const char *, nk_flags alignment)
NK_API int nk_slide_int(struct nk_context *, int min, int val, int max, int step)
Definition: nuklear.h:3732
NK_API int nk_filter_oct(const struct nk_text_edit *, nk_rune unicode)
float filled
Definition: nuklear.h:3741
#define NK_LEN(a)
Definition: nuklear.h:4054
NK_API struct nk_rect nk_recta(struct nk_vec2 pos, struct nk_vec2 size)
Definition: nuklear.h:2827
Definition: nuklear.h:2989
Definition: nuklear.h:693
NK_API int nk_slider_float(struct nk_context *, float min, float *val, float max, float step)
NK_API int nk_window_is_hidden(struct nk_context *, const char *)
NK_API void nk_fill_triangle(struct nk_command_buffer *, float x0, float y0, float x1, float y1, float x2, float y2, struct nk_color)
Definition: nuklear.h:1879
short cx
Definition: nuklear.h:2933
#define NK_INTERN
Definition: nuklear.h:286
struct nk_command_buffer buffer
Definition: nuklear.h:3851
NK_API int nk_slider_int(struct nk_context *, int min, int *val, int max, int step)
nk_size allocated
Definition: nuklear.h:2540
nk_hash name
Definition: nuklear.h:3837
Definition: nuklear.h:468
struct nk_vec2i end
Definition: nuklear.h:2859
NK_API int nk_contextual_item_image_label(struct nk_context *, struct nk_image, const char *, nk_flags alignment)
NK_API void nk_input_button(struct nk_context *, enum nk_buttons, int x, int y, int down)
NK_API int nk_item_is_any_active(struct nk_context *)
NK_API void nk_label_colored_wrap(struct nk_context *, const char *, struct nk_color)
struct nk_style_toggle checkbox
Definition: nuklear.h:3661
NK_API void nk_input_key(struct nk_context *, enum nk_keys, int down)
NK_API struct nk_style_item nk_style_item_color(struct nk_color)
Definition: nuklear.h:2849
#define SEEK_SET
Definition: zconf.h:388
Definition: nuklear.h:677
NK_API void nk_fill_rect(struct nk_command_buffer *, struct nk_rect, float rounding, struct nk_color)
NK_API int nk_button_push_behavior(struct nk_context *, enum nk_button_behavior)
unsigned short table_count
Definition: nuklear.h:3862
#define nk_ptr_add(t, p, i)
Definition: nuklear.h:4069
NK_API float nk_slide_float(struct nk_context *, float min, float val, float max, float step)
NK_API void nk_color_hsva_fv(float *hsva_out, struct nk_color)
Definition: nuklear.h:667
NK_API void nk_fill_polygon(struct nk_command_buffer *, float *, int point_count, struct nk_color)
nk_size size
Definition: nuklear.h:2561
short x
Definition: nuklear.h:2876
NK_API float nk_widget_width(struct nk_context *)
struct nk_color border_color
Definition: nuklear.h:3399
Definition: nuklear.h:1746
Definition: nuklear.h:3531
#define nk_vec2_add(a, b)
Definition: nuklear.h:4065
NK_API int nk_input_is_mouse_hovering_rect(const struct nk_input *, struct nk_rect)
float cursor_border
Definition: nuklear.h:3410
NK_API int nk_chart_begin(struct nk_context *, enum nk_chart_type, int num, float min, float max)
NK_API int nk_style_pop_vec2(struct nk_context *)
Definition: nuklear.h:2053
struct nk_config_stack_style_item style_items
Definition: nuklear.h:3953
NK_API nk_size nk_buffer_total(struct nk_buffer *)
nk_size size
Definition: nuklear.h:2539
Definition: nuklear.h:681
NK_API nk_handle nk_handle_ptr(void *)
unsigned short h
Definition: nuklear.h:2984
struct nk_style_item cursor_active
Definition: nuklear.h:3371
NK_API void nk_window_show(struct nk_context *, const char *name, enum nk_show_states)
struct nk_style style
Definition: nuklear.h:4007
Definition: nuklear.h:1751
NK_API void nk_tree_pop(struct nk_context *)
float range
Definition: nuklear.h:3708
const struct nk_user_font * font
Definition: nuklear.h:2991
Definition: gtest_output_test_.cc:544
NK_API void nk_textedit_undo(struct nk_text_edit *)
NK_API unsigned nk_check_flags_text(struct nk_context *, const char *, int, unsigned int flags, unsigned int value)
unsigned int count
Definition: nuklear.h:4041
struct nk_popup_state popup
Definition: nuklear.h:3857
NK_API float nk_layout_ratio_from_pixel(struct nk_context *, float pixel_width)
Definition: nuklear.h:1749
NK_API nk_flags nk_edit_buffer(struct nk_context *, nk_flags, struct nk_text_edit *, nk_plugin_filter)
float y
Definition: nuklear.h:457
short x
Definition: nuklear.h:456
struct nk_color right
Definition: nuklear.h:2896
Definition: nuklear.h:3695
NK_API int nk_style_pop_style_item(struct nk_context *)
nk_handle userdata
Definition: nuklear.h:2362
Definition: nuklear.h:497
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len)
Definition: adler32.c:60
nk_plugin_filter filter
Definition: nuklear.h:2727
void(* draw_begin)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:3416
NK_API int nk_checkbox_flags_label(struct nk_context *, const char *, unsigned int *flags, unsigned int value)
struct nk_color symbol_active
Definition: nuklear.h:3546
nk_rune undo_char[NK_TEXTEDIT_UNDOCHARCOUNT]
Definition: nuklear.h:2706
float scrollbar_hiding_timer
Definition: nuklear.h:3853
NK_API int nk_str_append_str_utf8(struct nk_str *, const char *)
nk_text_alignment
Definition: nuklear.h:1748
Definition: nuklear.h:2821
#define NK_API
Definition: nuklear.h:282
struct nk_rect bounds
Definition: nuklear.h:3849
Definition: nuklear.h:2714
unsigned short w
Definition: nuklear.h:2984
NK_API int nk_window_is_active(struct nk_context *, const char *)
Definition: nuklear.h:471
unsigned short line_thickness
Definition: nuklear.h:2919
Definition: nuklear.h:466
struct nk_style_window_header header
Definition: nuklear.h:3614
Definition: nuklear.h:3586
float global_alpha
Definition: nuklear.h:982
struct nk_command header
Definition: nuklear.h:2890
Definition: nuklear.h:2981
struct nk_color color
Definition: nuklear.h:2878
Definition: nuklear.h:470
unsigned capacity
Definition: nuklear.h:3999
NK_API int nk_style_push_color(struct nk_context *, struct nk_color *, struct nk_color)
struct nk_vec2 padding
Definition: nuklear.h:3528
Definition: nuklear.h:1886
NK_API void nk_style_load_all_cursors(struct nk_context *, struct nk_cursor *)
struct nk_vec2 touch_padding
Definition: nuklear.h:3346
struct nk_color color
Definition: nuklear.h:2950
struct nk_style_item fixed_background
Definition: nuklear.h:3615
Definition: nuklear.h:2019
nk_byte b
Definition: nuklear.h:453
NK_API int nk_input_has_mouse_click(const struct nk_input *, enum nk_buttons)
NK_API int nk_combo_begin_color(struct nk_context *, struct nk_color color, struct nk_vec2 size)
NK_API void nk_str_free(struct nk_str *)
int show_buttons
Definition: nuklear.h:3382
NK_API int nk_option_label(struct nk_context *, const char *, int active)
float border
Definition: nuklear.h:3409
nk_allocation_type
Definition: nuklear.h:2545
void(* nk_plugin_free)(nk_handle, void *old)
Definition: nuklear.h:479
struct nk_vec2i a
Definition: nuklear.h:2910
nk_plugin_paste paste
Definition: nuklear.h:2693
NK_API int nk_combo_begin_image_label(struct nk_context *, const char *selected, struct nk_image, struct nk_vec2 size)
nk_size next
Definition: nuklear.h:2843
struct nk_color color
Definition: nuklear.h:2958
struct nk_style_item background
Definition: nuklear.h:3564
Definition: nuklear.h:2034
NK_API void nk_textedit_free(struct nk_text_edit *)
struct nk_scroll scrollbar
Definition: nuklear.h:3850
NK_API void nk_color_hsva_iv(int *hsva_out, struct nk_color)
struct nk_buffer * base
Definition: nuklear.h:3007
float(* nk_text_width_f)(nk_handle, float h, const char *, int len)
Definition: nuklear.h:2343
int use_clipping
Definition: nuklear.h:3009
NK_API struct nk_command_buffer * nk_window_get_canvas(struct nk_context *)
NK_API int nk_checkbox_text(struct nk_context *, const char *, int, int *active)
nk_uint nk_hash
Definition: nuklear.h:404
NK_API int nk_str_len(struct nk_str *)
nk_command_type
Definition: nuklear.h:2818
NK_API nk_flags nk_edit_string(struct nk_context *, nk_flags, char *buffer, int *len, int max, nk_plugin_filter)
NK_API void nk_edit_unfocus(struct nk_context *)
unsigned int old
Definition: nuklear.h:3820
nk_size calls
Definition: nuklear.h:2542
Definition: nuklear.h:686
Definition: nuklear.h:1745
struct nk_vec2 pos
Definition: nuklear.h:3050
Definition: nuklear.h:2551
struct nk_style_item hover
Definition: nuklear.h:3490
Definition: nuklear.h:684
NK_API int nk_combo_item_image_text(struct nk_context *, struct nk_image, const char *, int, nk_flags alignment)
NK_API int nk_combo_begin_symbol_text(struct nk_context *, const char *selected, int, enum nk_symbol_type, struct nk_vec2 size)
Definition: nuklear.h:2045
#define NK_INPUT_MAX
Definition: nuklear.h:257
NK_API int nk_menu_begin_symbol_label(struct nk_context *, const char *, nk_flags align, enum nk_symbol_type, struct nk_vec2 size)
Definition: nuklear.h:1893
NK_API void nk_buffer_free(struct nk_buffer *)
Definition: nuklear.h:2831
NK_API struct nk_color nk_hsv_f(float h, float s, float v)
nk_hash name
Definition: nuklear.h:3845
struct nk_style_item cursor_active
Definition: nuklear.h:3404
struct nk_color color
Definition: nuklear.h:2921
struct nk_style_item normal
Definition: nuklear.h:3357
NK_API int nk_button_symbol(struct nk_context *, enum nk_symbol_type)
NK_API int nk_checkbox_label(struct nk_context *, const char *, int *active)
int use_pool
Definition: nuklear.h:4034
struct nk_vec2 scroll_delta
Definition: nuklear.h:3053
NK_API int nk_window_is_closed(struct nk_context *, const char *)
struct nk_vec2 padding
Definition: nuklear.h:3309
Definition: nuklear.h:469
Definition: nuklear.h:685
NK_API int nk_group_begin(struct nk_context *, const char *title, nk_flags)
Definition: nuklear.h:2971
Definition: nuklear.h:2916
NK_API void nk_buffer_info(struct nk_memory_status *, struct nk_buffer *)
NK_API const char * nk_str_at_const(const struct nk_str *, int pos, nk_rune *unicode, int *len)
struct nk_color symbol_normal
Definition: nuklear.h:3544
struct nk_vec2 delta
Definition: nuklear.h:3052
Definition: nuklear.h:3952
#define NK_COLOR_STACK_SIZE
Definition: nuklear.h:3921
float row_padding
Definition: nuklear.h:3484
struct nk_style_item normal
Definition: nuklear.h:3292
enum nk_panel_row_layout_type type
Definition: nuklear.h:3733
NK_API void nk_color_hsv_i(int *out_h, int *out_s, int *out_v, struct nk_color)
Definition: nuklear.h:981
#define NK_BETWEEN(x, a, b)
Definition: nuklear.h:4056
NK_API struct nk_rect nk_window_get_bounds(const struct nk_context *ctx)
NK_API void nk_clear(struct nk_context *)
struct nk_color cursor_border_color
Definition: nuklear.h:3405
Definition: nuklear.h:2021
Definition: nuklear.h:674
float w
Definition: nuklear.h:457
struct nk_color border_color
Definition: nuklear.h:3492
NK_API void nk_menu_end(struct nk_context *)
#define NK_CONTAINER_OF(ptr, type, member)
Definition: nuklear.h:4097
struct nk_style_item hover
Definition: nuklear.h:3323
NK_API int nk_selectable_image_text(struct nk_context *, struct nk_image, const char *, int, nk_flags align, int *value)
NK_API nk_flags nk_chart_push(struct nk_context *, float)
NK_API unsigned nk_check_flags_label(struct nk_context *, const char *, unsigned int flags, unsigned int value)
float rounding
Definition: nuklear.h:3344
NK_API int nk_begin_titled(struct nk_context *ctx, const char *name, const char *title, struct nk_rect bounds, nk_flags flags)
NK_API float nk_propertyf(struct nk_context *, const char *name, float min, float val, float max, float step, float inc_per_pixel)
NK_API int nk_input_is_key_released(const struct nk_input *, enum nk_keys)
Definition: nuklear.h:495
struct nk_color cursor_hover
Definition: nuklear.h:3463
struct nk_style_item hover
Definition: nuklear.h:3397
Definition: nuklear.h:2863
Definition: nuklear.h:2948
enum nk_command_type type
Definition: nuklear.h:2842
float rounding
Definition: nuklear.h:3556
struct nk_color text_active
Definition: nuklear.h:3470
NK_API struct nk_rect nk_widget_bounds(struct nk_context *)
struct nk_config_stack_vec2 vectors
Definition: nuklear.h:3955
float border
Definition: nuklear.h:3577
Definition: nuklear.h:473
Definition: nuklear.h:2824
short y
Definition: nuklear.h:2851
NK_API void nk_window_show_if(struct nk_context *, const char *name, enum nk_show_states, int cond)
NK_API int nk_tree_image_push_hashed(struct nk_context *, enum nk_tree_type, struct nk_image, const char *title, enum nk_collapse_states initial_state, const char *hash, int len, int seed)
nk_color_format
Definition: nuklear.h:473
struct nk_command header
Definition: nuklear.h:2990
float combo_border
Definition: nuklear.h:3628
struct nk_color cursor_normal
Definition: nuklear.h:3462
struct nk_command header
Definition: nuklear.h:2982
nk_hash keys[NK_VALUE_PAGE_CAPACITY]
Definition: nuklear.h:3970
NK_API struct nk_color nk_hsv_iv(const int *hsv)
NK_API int nk_menu_begin_image(struct nk_context *, const char *, struct nk_image, struct nk_vec2 size)
struct nk_color popup_border_color
Definition: nuklear.h:3619
NK_API int nk_menu_begin_image_label(struct nk_context *, const char *, nk_flags align, struct nk_image, struct nk_vec2 size)
Definition: nuklear.h:3981
NK_API int nk_str_insert_at_char(struct nk_str *, int pos, const char *, int)
Definition: nuklear.h:1711
Definition: nuklear.h:2691
NK_API int nk_selectable_text(struct nk_context *, const char *, int, nk_flags align, int *value)
NK_UINT16 nk_ushort
Definition: nuklear.h:398
Definition: nuklear.h:2963
Definition: nuklear.h:1742
Definition: nuklear.h:3795
unsigned int old
Definition: nuklear.h:3839
nk_size size
Definition: nuklear.h:2579
enum nk_panel_type type
Definition: nuklear.h:3761
NK_API int nk_input_is_mouse_down(const struct nk_input *, enum nk_buttons)
NK_API nk_size nk_prog(struct nk_context *, nk_size cur, nk_size max, int modifyable)
NK_API int nk_filter_float(const struct nk_text_edit *, nk_rune unicode)
struct nk_vec2i begin
Definition: nuklear.h:2866
Definition: nuklear.h:3789
nk_handle callback_data
Definition: nuklear.h:2985
NK_API void nk_input_end(struct nk_context *)
NK_API int nk_button_pop_behavior(struct nk_context *)
float h
Definition: nuklear.h:457
struct nk_color selected_normal
Definition: nuklear.h:3473
NK_API void nk_layout_row(struct nk_context *, enum nk_layout_format, float height, int cols, const float *ratio)
NK_API void nk_layout_row_template_end(struct nk_context *)
Definition: nuklear.h:2042
Definition: nuklear.h:1721
float rounding
Definition: nuklear.h:3635
void(* draw_end)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:3391
NK_API struct nk_color nk_hsva_f(float h, float s, float v, float a)
struct nk_style_edit edit
Definition: nuklear.h:3508
NK_API int nk_combo_string(struct nk_context *, const char *items_separated_by_zeros, int selected, int count, int item_height, struct nk_vec2 size)
struct nk_style_toggle option
Definition: nuklear.h:3660
struct nk_panel pan
Definition: nuklear.h:3977
Definition: nuklear.h:678
NK_API int nk_strmatch_fuzzy_string(char const *str, char const *pattern, int *out_score)
struct nk_buffer_marker marker[NK_BUFFER_MAX]
Definition: nuklear.h:2563
NK_API int nk_combo_begin_image_text(struct nk_context *, const char *selected, int, struct nk_image, struct nk_vec2 size)
Definition: nuklear.h:2834
Definition: nuklear.h:2035
char string[1]
Definition: nuklear.h:2998
Definition: nuklear.h:2048
int heuristic(Location a, Location b)
Definition: findpath.cpp:58
nk_plugin_copy copy
Definition: nuklear.h:2694
Definition: nuklear.h:3258
struct nk_vec2 size offset
Definition: nuklear.h:462
struct nk_style_item normal
Definition: nuklear.h:3396
NK_API int nk_selectable_image_label(struct nk_context *, struct nk_image, const char *, nk_flags align, int *value)
Definition: nuklear.h:666
struct nk_style_button node_minimize_button
Definition: nuklear.h:3572
Definition: nuklear.h:3730
unsigned short line_thickness
Definition: nuklear.h:2935
NK_API int nk_check_text(struct nk_context *, const char *, int, int active)
short y
Definition: nuklear.h:2994
struct nk_text_edit text_edit
Definition: nuklear.h:4028
NK_API int nk_style_push_style_item(struct nk_context *, struct nk_style_item *, struct nk_style_item)
Definition: nuklear.h:2050
NK_API void nk_textedit_delete(struct nk_text_edit *, int where, int len)
int slot
Definition: nuklear.h:3715
NK_API nk_hash nk_murmur_hash(const void *key, int len, nk_hash seed)
struct nk_style_item active
Definition: nuklear.h:3294
char name_string[NK_WINDOW_MAX_NAME]
Definition: nuklear.h:3846
Definition: nuklear.h:4004
typedef int(ENET_CALLBACK *ENetInterceptCallback)(struct _ENetHost *host
Definition: nuklear.h:2855
struct nk_page_element * prev
Definition: nuklear.h:3984
short x
Definition: nuklear.h:458
enum nk_anti_aliasing shape_AA
Definition: nuklear.h:984
Definition: nuklear.h:1710
struct nk_rect clip
Definition: nuklear.h:3008
struct nk_panel * layout
Definition: nuklear.h:3852
int length
Definition: nuklear.h:2997
NK_API void nk_style_set_font(struct nk_context *, const struct nk_user_font *)
struct nk_color left
Definition: nuklear.h:2893
Definition: nuklear.h:2872
struct nk_str string
Definition: nuklear.h:2726
nk_handle userdata
Definition: nuklear.h:3513
Definition: nuklear.h:466
Definition: nuklear.h:1884
#define const
Definition: zconf.h:196
short char_storage
Definition: nuklear.h:2701
short redo_char_point
Definition: nuklear.h:2710
int sel_start
Definition: nuklear.h:3823
struct nk_command header
Definition: nuklear.h:2864
short x
Definition: nuklear.h:2983
struct nk_clipboard clip
Definition: nuklear.h:4009
NK_API void nk_color_hsv_b(nk_byte *out_h, nk_byte *out_s, nk_byte *out_v, struct nk_color)
struct nk_vec2 content_padding
Definition: nuklear.h:3557
unsigned short line_thickness
Definition: nuklear.h:2875
enum nk_style_item_type type
Definition: nuklear.h:3254
NK_API void nk_label_colored(struct nk_context *, const char *, nk_flags align, struct nk_color)
Definition: nuklear.h:3830
Definition: nuklear.h:471
struct nk_color text_normal
Definition: nuklear.h:3302
Definition: nuklear.h:690
struct nk_color label_hover
Definition: nuklear.h:3540
Definition: nuklear.h:2044
NK_API int nk_check_label(struct nk_context *, const char *, int active)
struct nk_command header
Definition: nuklear.h:2941
NK_API void nk_window_set_bounds(struct nk_context *, struct nk_rect bounds)
nk_layout_format
Definition: nuklear.h:475
struct nk_color bar_filled
Definition: nuklear.h:3366
Definition: nuklear.h:2051
Definition: nuklear.h:3290
Definition: nuklear.h:452
Definition: nuklear.h:3002
short y
Definition: nuklear.h:456
NK_API void nk_end(struct nk_context *ctx)
NK_API int nk_menu_begin_symbol(struct nk_context *, const char *, enum nk_symbol_type, struct nk_vec2 size)
NK_API int nk_strfilter(const char *text, const char *regexp)
NK_API void nk_combobox_string(struct nk_context *, const char *items_separated_by_zeros, int *selected, int count, int item_height, struct nk_vec2 size)
nk_text_width_f width
Definition: nuklear.h:2366
char buffer[NK_MAX_NUMBER_BUFFER]
Definition: nuklear.h:3832
Definition: nuklear.h:494
void(* draw_begin)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:3316
NK_API char * nk_str_get(struct nk_str *)
NK_UINT8 nk_byte
Definition: nuklear.h:396
#define NK_CHART_MAX_SLOT
Definition: nuklear.h:3686
struct nk_text_undo_record undo_rec[NK_TEXTEDIT_UNDOSTATECOUNT]
Definition: nuklear.h:2705
unsigned short h
Definition: nuklear.h:2877
Definition: nuklear.h:2561
Definition: nuklear.h:460
Definition: nuklear.h:493
NK_API int nk_str_append_str_runes(struct nk_str *, const nk_rune *)
NK_API struct nk_color nk_rgba_fv(const float *rgba)
struct nk_config_stack_float floats
Definition: nuklear.h:3954
struct nk_style_button tab_maximize_button
Definition: nuklear.h:3569
#define NK_UNUSED(x)
Definition: nuklear.h:4052
int down
Definition: nuklear.h:3060
Definition: nuklear.h:3253
NK_INT16 nk_short
Definition: nuklear.h:397
short x
Definition: nuklear.h:2884
NK_API struct nk_vec2 nk_window_get_content_region_size(struct nk_context *)
Definition: nuklear.h:1877
NK_API struct nk_vec2 nk_window_get_content_region_max(struct nk_context *)
NK_API struct nk_rect nk_window_get_content_region(struct nk_context *)
NK_API int nk_select_image_label(struct nk_context *, struct nk_image, const char *, nk_flags align, int value)
float grow_factor
Definition: nuklear.h:2571
struct nk_vec2 uv
Definition: nuklear.h:979
nk_uint * scroll_pointer
Definition: nuklear.h:1684
Definition: nuklear.h:452
Definition: nuklear.h:471
NK_API void nk_layout_space_begin(struct nk_context *, enum nk_layout_format, float height, int widget_count)
unsigned int seq
Definition: nuklear.h:4042
Definition: nuklear.h:454
int select_end
Definition: nuklear.h:3836
nk_text_edit_mode
Definition: nuklear.h:2718
struct nk_config_stack_color colors
Definition: nuklear.h:3957
struct nk_edit_state edit
Definition: nuklear.h:3858
struct nk_color label_active
Definition: nuklear.h:3541
NK_API void nk_style_from_table(struct nk_context *, const struct nk_color *)
int sel_end
Definition: nuklear.h:3824
#define NK_UINT8
Definition: nuklear.h:340
struct nk_input input
Definition: nuklear.h:4006
NK_API int nk_button_label(struct nk_context *, const char *title)
#define NK_MAX(a, b)
Definition: nuklear.h:316
const struct nk_user_font * font
Definition: nuklear.h:3650
enum nk_button_behavior button_behavior
Definition: nuklear.h:4011
unsigned short table_size
Definition: nuklear.h:3863
NK_API int nk_button_text(struct nk_context *, const char *title, int len)
#define NK_CONTAINS(x, y, w, h, bx, by, bw, bh)
Definition: nuklear.h:4061
NK_API void nk_menubar_begin(struct nk_context *)
NK_API int nk_style_push_float(struct nk_context *, float *, float)
#define NK_PTR_TO_UINT(x)
Definition: nuklear.h:4082
#define NK_FONT_STACK_SIZE
Definition: nuklear.h:3901
NK_API int nk_combo_item_label(struct nk_context *, const char *, nk_flags alignment)
NK_API int nk_button_image_label(struct nk_context *, struct nk_image img, const char *, nk_flags text_alignment)
NK_API int nk_button_image_text(struct nk_context *, struct nk_image img, const char *, int, nk_flags alignment)
Definition: nuklear.h:673
Definition: nuklear.h:2697
NK_API void nk_color_hsv_fv(float *hsv_out, struct nk_color)
NK_API int nk_str_insert_str_char(struct nk_str *, int pos, const char *)
struct nk_vec2i points[1]
Definition: nuklear.h:2968
Definition: nuklear.h:2018
struct nk_vec2 padding
Definition: nuklear.h:3377
NK_API int nk_menu_begin_label(struct nk_context *, const char *, nk_flags align, struct nk_vec2 size)
unsigned char grabbed
Definition: nuklear.h:3055
NK_API void nk_color_hsva_f(float *out_h, float *out_s, float *out_v, float *out_a, struct nk_color)
unsigned char mode
Definition: nuklear.h:3826
NK_API int nk_style_pop_flags(struct nk_context *)
NK_API int nk_button_symbol_text_styled(struct nk_context *, const struct nk_style_button *, enum nk_symbol_type, const char *, int, nk_flags alignment)
NK_API struct nk_color nk_rgb_hex(const char *rgb)
struct nk_style_item hover
Definition: nuklear.h:3534
nk_symbol_type
Definition: nuklear.h:489
NK_API struct nk_color nk_rgb_bv(const nk_byte *rgb)
NK_API int nk_str_insert_str_utf8(struct nk_str *, int pos, const char *)
struct nk_allocator pool
Definition: nuklear.h:2565
NK_API struct nk_image nk_subimage_id(int, unsigned short w, unsigned short h, struct nk_rect sub_region)
struct nk_color text_background
Definition: nuklear.h:3305
short cy
Definition: nuklear.h:2942
Definition: nuklear.h:687
NK_API void nk_plot_function(struct nk_context *, enum nk_chart_type, void *userdata, float(*value_getter)(void *user, int index), int count, int offset)
NK_API nk_rune nk_str_rune_at(const struct nk_str *, int pos)
NK_API int nk_style_pop_font(struct nk_context *)
struct nk_style_item hover
Definition: nuklear.h:3293
nk_command_clipping
Definition: nuklear.h:3001
tuple output
Definition: gtest_output_test.py:321
Definition: nuklear.h:3063
int columns
Definition: nuklear.h:3736
unsigned short r
Definition: nuklear.h:2934
int text_len
Definition: nuklear.h:3066
NK_INT32 nk_int
Definition: nuklear.h:399
NK_API int nk_tree_state_push(struct nk_context *, enum nk_tree_type, const char *title, enum nk_collapse_states *state)
float border
Definition: nuklear.h:3479
NK_API void nk_input_unicode(struct nk_context *, nk_rune)
Definition: nuklear.h:698
NK_API void nk_textedit_redo(struct nk_text_edit *)
NK_API void nk_menu_close(struct nk_context *)
Definition: nuklear.h:472
NK_API struct nk_vec2 nk_rect_size(struct nk_rect)
Definition: nuklear.h:671
struct nk_style_item background
Definition: nuklear.h:3520
NK_API void nk_str_init(struct nk_str *, const struct nk_allocator *, nk_size size)
NK_API struct nk_image nk_image_id(int)
short y
Definition: nuklear.h:2884
struct nk_color color
Definition: nuklear.h:2937
Definition: nuklear.h:3726
NK_API int nk_combo_begin_image(struct nk_context *, struct nk_image img, struct nk_vec2 size)
Definition: nuklear.h:2820
#define nk_vec2_len_sqr(a)
Definition: nuklear.h:4066
struct nk_style_button inc_button
Definition: nuklear.h:3509
struct nk_command header
Definition: nuklear.h:2917
Definition: nuklear.h:2055
Definition: nuklear.h:3245
NK_API void nk_color_d(double *r, double *g, double *b, double *a, struct nk_color)
NK_API void nk_combo_end(struct nk_context *)
Definition: nuklear.h:2833
NK_API int nk_propertyi(struct nk_context *, const char *name, int min, int val, int max, int step, float inc_per_pixel)
Definition: nuklear.h:3693
nk_size calls
Definition: nuklear.h:2577
NK_API void nk_input_char(struct nk_context *, char)
Definition: nuklear.h:2881
NK_API void nk_color_dv(double *rgba_out, struct nk_color)
struct nk_page_element win[1]
Definition: nuklear.h:3990
#define NK_INTERSECT(x0, y0, w0, h0, x1, y1, w1, h1)
Definition: nuklear.h:4059
NK_API struct nk_vec2 nk_vec2v(const float *xy)
NK_API int nk_tooltip_begin(struct nk_context *, float width)
void(* draw_end)(struct nk_command_buffer *, nk_handle)
Definition: nuklear.h:3317
NK_API struct nk_rect nk_recti(int x, int y, int w, int h)
NK_API struct nk_panel * nk_window_get_panel(struct nk_context *)
struct nk_vec2 menu_padding
Definition: nuklear.h:3645
struct nk_color label_normal
Definition: nuklear.h:3495
nk_size offset
Definition: nuklear.h:2558
nk_show_states
Definition: nuklear.h:470
struct nk_color color
Definition: nuklear.h:3259
struct nk_style_item pressed
Definition: nuklear.h:3324
NK_API int nk_style_pop_color(struct nk_context *)
NK_API struct nk_color nk_rgba_iv(const int *rgba)
unsigned char single_line
Definition: nuklear.h:3827
struct nk_color selected_hover
Definition: nuklear.h:3474
NK_API void nk_chart_end(struct nk_context *)
short x
Definition: nuklear.h:2926
struct nk_command_buffer * buffer
Definition: nuklear.h:3775
float a
Definition: nuklear.h:454
struct nk_color menu_border_color
Definition: nuklear.h:3622
NK_API int nk_menu_item_symbol_label(struct nk_context *, enum nk_symbol_type, const char *, nk_flags alignment)
Definition: nuklear.h:465
Definition: nuklear.h:1744
Definition: nuklear.h:3722
NK_API int nk_combo_begin_symbol_label(struct nk_context *, const char *selected, enum nk_symbol_type, struct nk_vec2 size)
Definition: nuklear.h:472
#define NK_ALIGN_PTR_BACK(x, mask)
Definition: nuklear.h:4093
NK_API int nk_style_push_vec2(struct nk_context *, struct nk_vec2 *, struct nk_vec2)
nk_heading
Definition: nuklear.h:465
#define nk_vec2_muls(a, t)
Definition: nuklear.h:4067
nk_style_colors
Definition: nuklear.h:2016
NK_API struct nk_vec2 nk_window_get_content_region_min(struct nk_context *)
NK_API int nk_menu_begin_text(struct nk_context *, const char *title, int title_len, nk_flags align, struct nk_vec2 size)
struct nk_color background
Definition: nuklear.h:2992
struct nk_vec2i end
Definition: nuklear.h:2867
nk_handle userdata
Definition: nuklear.h:3010
Definition: nuklear.h:491
NK_API struct nk_rect nk_rectiv(const int *xywh)
unsigned short h
Definition: nuklear.h:461
struct nk_color border_color
Definition: nuklear.h:3565
NK_API struct nk_vec2 nk_widget_size(struct nk_context *)
NK_API void nk_layout_row_push(struct nk_context *, float value)
nk_flags text_alignment
Definition: nuklear.h:3306